<?php
$credit = 4000 ;
$stavka = 0.03 ;
$payment = 5000 ;
$komissiya = 1000 ;
$totalPayment = 0 ;
for ( $period = 1 ; $period < 20 ; $period ++ ) {
$credit = $credit + ( $credit * $stavka ) ;
$credit = $credit - $payment + $komissiya ;
echo "Шел $period месяц, кредит составлял $credit рублей <br>" ;
if ( $credit + $komissiya < $payment ) {
$period ++;
$lastPayment = $payment - ( $credit + $komissiya ) ;
echo "Сдача с последнего платежа: $lastPayment рублей, <br>" ;
$lastPayment = $payment - $lastPayment ;
echo "Последний платеж в $period мес. (включая комиссию) составил $lastPayment рублей<br>" ;
break ;
}
if ( $credit < 0 ) {
echo "Кредит выплачен!" ;
break ;
}
}
?>
Cjw/cGhwCmVycm9yX3JlcG9ydGluZygtMSk7CiRjcmVkaXQgPSA0MDAwOwokc3RhdmthID0gMC4wMzsKJHBheW1lbnQgPSA1MDAwOwoka29taXNzaXlhID0gMTAwMDsKJHRvdGFsUGF5bWVudCA9IDA7CgoKCmZvcigkcGVyaW9kID0gMTsgJHBlcmlvZCA8IDIwOyAkcGVyaW9kKyspewoKICAgICRjcmVkaXQgPSAkY3JlZGl0ICsgKCRjcmVkaXQgKiAkc3RhdmthKTsKICAgICRjcmVkaXQgPSAkY3JlZGl0IC0gJHBheW1lbnQgKyAka29taXNzaXlhOwoKICAgIGVjaG8gItCo0LXQuyAkcGVyaW9kINC80LXRgdGP0YYsINC60YDQtdC00LjRgiDRgdC+0YHRgtCw0LLQu9GP0LsgJGNyZWRpdCDRgNGD0LHQu9C10LkgPGJyPiI7CgogICAgaWYgKCRjcmVkaXQgKyAka29taXNzaXlhIDwgJHBheW1lbnQpewogICAgICAgICRwZXJpb2QrKzsKICAgICAgICAkbGFzdFBheW1lbnQgPSAkcGF5bWVudCAtICgkY3JlZGl0ICsgJGtvbWlzc2l5YSk7CiAgICAgICAgZWNobyAi0KHQtNCw0YfQsCDRgSDQv9C+0YHQu9C10LTQvdC10LPQviDQv9C70LDRgtC10LbQsDogJGxhc3RQYXltZW50INGA0YPQsdC70LXQuSwgPGJyPiI7CiAgICAgICAgJGxhc3RQYXltZW50ID0gJHBheW1lbnQgLSAkbGFzdFBheW1lbnQ7CiAgICAgICAgZWNobyAi0J/QvtGB0LvQtdC00L3QuNC5INC/0LvQsNGC0LXQtiDQsiAkcGVyaW9kINC80LXRgS4gKNCy0LrQu9GO0YfQsNGPINC60L7QvNC40YHRgdC40Y4pINGB0L7RgdGC0LDQstC40LsgJGxhc3RQYXltZW50INGA0YPQsdC70LXQuTxicj4iOwogICAgICAgIGJyZWFrOwogICAgfQoKICAgIGlmICgkY3JlZGl0IDwgMCl7CiAgICAgICAgZWNobyAi0JrRgNC10LTQuNGCINCy0YvQv9C70LDRh9C10L0hIjsKICAgICAgICBicmVhazsKICAgIH0KCn0KCgo/Pg==