<?php
$creditBalance = 39999;
$monthlyPayment = 5000;
$totalPayment = 0;
$percent = 1.03;
$payment = 1000;
do {
for($month =1; $month <=20; $month ++) {
$creditBalance = ( $creditBalance * $percent ) + $payment - $monthlyPayment;
$paymentTotal = $paymentTotal + $monthlyPayment;
echo "Месяц {$month} долг {$creditBalance} выплачено {$paymentTotal}\n";
if (( $creditBalance * $percent ) + $payment <= $monthlyPayment) {
$monthlyPayment = $creditBalance;
}
} while ($creditBalance == 0);
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgokY3JlZGl0QmFsYW5jZSA9IDM5OTk5OyAKJG1vbnRobHlQYXltZW50ID0gNTAwMDsKJHRvdGFsUGF5bWVudCA9IDA7CiRwZXJjZW50ID0gMS4wMzsKJHBheW1lbnQgPSAxMDAwOwoKZG8gewogIGZvcigkbW9udGggPTE7ICRtb250aCA8PTIwOyAkbW9udGggKyspIHsKICAkY3JlZGl0QmFsYW5jZSA9ICggJGNyZWRpdEJhbGFuY2UgKiAkcGVyY2VudCApICsgJHBheW1lbnQgLSAkbW9udGhseVBheW1lbnQ7CiAgJHBheW1lbnRUb3RhbCA9ICRwYXltZW50VG90YWwgKyAkbW9udGhseVBheW1lbnQ7CiAgZWNobyAi0JzQtdGB0Y/RhiB7JG1vbnRofSDQtNC+0LvQsyB7JGNyZWRpdEJhbGFuY2V9INCy0YvQv9C70LDRh9C10L3QviB7JHBheW1lbnRUb3RhbH1cbiI7CiAgaWYgKCggJGNyZWRpdEJhbGFuY2UgKiAkcGVyY2VudCApICsgJHBheW1lbnQgPD0gJG1vbnRobHlQYXltZW50KSB7CiAgJG1vbnRobHlQYXltZW50ID0gJGNyZWRpdEJhbGFuY2U7CiAgfQp9IHdoaWxlICgkY3JlZGl0QmFsYW5jZSA9PSAwKTs=