<?php
$creditBalance = 40000;
$percent = 1.03;
$servicePayment = 1000;
$monthlyPayment = 5000;
$paymentTotal = 0;
$break = 0;
for ($month = 1; $month <= 20; $month++) {
$creditBalance = ($creditBalance * $percent) + $servicePayment - $monthlyPayment;
$paymentTotal = ($paymentTotal + $monthlyPayment);
$break = ($paymentTotal - $monthlyPayment);
echo "{$month} месяц спустя: долг = {$creditBalance} руб, выплачено всего {$paymentTotal} руб.\n";
if ($creditBalance < 5000); {
$monthlyPayment = ($break + $creditBalance);
echo "с меня хватит!\n";
break;
}
}
PD9waHAKCiRjcmVkaXRCYWxhbmNlID0gNDAwMDA7CiRwZXJjZW50ID0gMS4wMzsKJHNlcnZpY2VQYXltZW50ID0gMTAwMDsKJG1vbnRobHlQYXltZW50ID0gNTAwMDsKJHBheW1lbnRUb3RhbCA9IDA7CiRicmVhayA9IDA7Cgpmb3IgKCRtb250aCA9IDE7ICRtb250aCA8PSAyMDsgJG1vbnRoKyspIHsKCQoJJGNyZWRpdEJhbGFuY2UgPSAoJGNyZWRpdEJhbGFuY2UgKiAkcGVyY2VudCkgKyAkc2VydmljZVBheW1lbnQgLSAkbW9udGhseVBheW1lbnQ7CgkkcGF5bWVudFRvdGFsID0gKCRwYXltZW50VG90YWwgKyAkbW9udGhseVBheW1lbnQpOwoJJGJyZWFrID0gKCRwYXltZW50VG90YWwgLSAkbW9udGhseVBheW1lbnQpOwoJZWNobyAieyRtb250aH0g0LzQtdGB0Y/RhiDRgdC/0YPRgdGC0Y86INC00L7Qu9CzID0geyRjcmVkaXRCYWxhbmNlfSDRgNGD0LEsINCy0YvQv9C70LDRh9C10L3QviDQstGB0LXQs9C+IHskcGF5bWVudFRvdGFsfSDRgNGD0LEuXG4iOwoJCglpZiAoJGNyZWRpdEJhbGFuY2UgPCA1MDAwKTsgewoJJG1vbnRobHlQYXltZW50ID0gKCRicmVhayArICRjcmVkaXRCYWxhbmNlKTsKCWVjaG8gItGBINC80LXQvdGPINGF0LLQsNGC0LjRgiFcbiI7CglicmVhazsKCX0KfQ==