<?php
$creditSum = 1000;
$monthPercent = 1.03;
$monthComission = 1000;
$monthPay = 5000;
$total = 0;
for ($month = 1; $month <= 20; $month++) {
$creditSum = ($creditSum * $monthPercent) + $monthComission - $monthPay;
$total = $total + $monthPay;
echo "Анон платит {$month}-й месяц. Заплатил уже {$total}. Остаток задолженности {$creditSum}.\n";
if ($creditSum < 0) {
$monthPay = $creditSum;
$total = $total + $monthPay;
$creditSum = $creditSum - $monthPay;
$month = $month + 1;
echo "Анон платит {$month}-й месяц. Заплатил уже {$total}. Остаток задолженности {$creditSum}.\n";
break;
}
}
?>
PD9waHAKJGNyZWRpdFN1bSA9IDEwMDA7CiRtb250aFBlcmNlbnQgPSAxLjAzOwokbW9udGhDb21pc3Npb24gPSAxMDAwOwokbW9udGhQYXkgPSA1MDAwOwokdG90YWwgPSAwOwoKZm9yICgkbW9udGggPSAxOyAkbW9udGggPD0gMjA7ICRtb250aCsrKSB7CgkkY3JlZGl0U3VtID0gKCRjcmVkaXRTdW0gKiAkbW9udGhQZXJjZW50KSArICRtb250aENvbWlzc2lvbiAtICRtb250aFBheTsKCSR0b3RhbCA9ICR0b3RhbCArICRtb250aFBheTsKCWVjaG8gItCQ0L3QvtC9INC/0LvQsNGC0LjRgiB7JG1vbnRofS3QuSDQvNC10YHRj9GGLiDQl9Cw0L/Qu9Cw0YLQuNC7INGD0LbQtSB7JHRvdGFsfS4g0J7RgdGC0LDRgtC+0Log0LfQsNC00L7Qu9C20LXQvdC90L7RgdGC0LggeyRjcmVkaXRTdW19LlxuIjsKICAgIGlmICgkY3JlZGl0U3VtIDwgMCkgewoJJG1vbnRoUGF5ID0gJGNyZWRpdFN1bTsKCSR0b3RhbCA9ICR0b3RhbCArICRtb250aFBheTsKCSRjcmVkaXRTdW0gPSAkY3JlZGl0U3VtIC0gJG1vbnRoUGF5OwoJJG1vbnRoID0gJG1vbnRoICsgMTsKCWVjaG8gItCQ0L3QvtC9INC/0LvQsNGC0LjRgiB7JG1vbnRofS3QuSDQvNC10YHRj9GGLiDQl9Cw0L/Qu9Cw0YLQuNC7INGD0LbQtSB7JHRvdGFsfS4g0J7RgdGC0LDRgtC+0Log0LfQsNC00L7Qu9C20LXQvdC90L7RgdGC0LggeyRjcmVkaXRTdW19LlxuIjsKCWJyZWFrOwp9Cn0KPz4=