<?php
$creditBalance = 40000;
$percent = 1.03;
$servicePayment = 1000;
$monthlyPayment = 5000;
$paymentTotal = 0;
for ($month = 1; $month <= 20; $month ++)
if ($creditBalance >= 5000) {
$creditBalance = $creditBalance - $monthlyPayment;
$paymentTotal = $paymentTotal + $monthlyPayment;
$creditBalance = ($creditBalance * $percent) + $servicePayment;
echo "{$month} месяц спустя: долг = {$creditBalance} руб, выплачено всего {$paymentTotal} руб. \n";
}
else {
$x = $creditBalance;
$paymentTotal = $paymentTotal + $x;
echo "На {$month} месяц долг составляет {$creditBalance} руб, сумма последней выплаты составляет {$x}, выплачено всего {$paymentTotal} руб. \n";
$creditBalance = $creditBalance - $x;
echo "Аноним полностью выплатил кредит за {$month} месяцев.\nАйфон обошелся в {$paymentTotal}\n";
}
}
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgokY3JlZGl0QmFsYW5jZSA9IDQwMDAwOwokcGVyY2VudCA9IDEuMDM7CiRzZXJ2aWNlUGF5bWVudCA9IDEwMDA7CiRtb250aGx5UGF5bWVudCA9IDUwMDA7CiRwYXltZW50VG90YWwgPSAwOwoKZm9yICgkbW9udGggPSAxOyAkbW9udGggPD0gMjA7ICRtb250aCArKykgCgogICAgaWYgKCRjcmVkaXRCYWxhbmNlID49IDUwMDApIHsKCQkkY3JlZGl0QmFsYW5jZSA9ICRjcmVkaXRCYWxhbmNlIC0gJG1vbnRobHlQYXltZW50OwoJCSRwYXltZW50VG90YWwgPSAkcGF5bWVudFRvdGFsICsgJG1vbnRobHlQYXltZW50OwoJCQokY3JlZGl0QmFsYW5jZSA9ICgkY3JlZGl0QmFsYW5jZSAqICRwZXJjZW50KSArICRzZXJ2aWNlUGF5bWVudDsKCmVjaG8gInskbW9udGh9INC80LXRgdGP0YYg0YHQv9GD0YHRgtGPOiDQtNC+0LvQsyA9IHskY3JlZGl0QmFsYW5jZX0g0YDRg9CxLCDQstGL0L/Qu9Cw0YfQtdC90L4g0LLRgdC10LPQviB7JHBheW1lbnRU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