<?php
$creditBalance = 40000;
$creditPercent = 1.03;
$creditComission = 1000;
$monthlyPayment = 5000;
$paymentTotal = 0;
$extraPayment = "x"
for ($month=1; $month <= 20; $month++) {
$creditBalance = ($creditBalance * $creditPercent) + $creditComission - $monthlyPayment;
$paymentTotal = $paymentTotal + $monthlyPayment;
echo "{$month} месяц спустя: долг = {$creditBalance} руб, выплачено всего {$paymentTotal} руб.\n";
if ($creditBalance < 5000) {
$creditBalance = $paymentTotal - "x";
echo "С меня хватит!\n";
break;
}
}
?>
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CiRjcmVkaXRCYWxhbmNlID0gNDAwMDA7CiRjcmVkaXRQZXJjZW50ID0gMS4wMzsKJGNyZWRpdENvbWlzc2lvbiA9IDEwMDA7CiRtb250aGx5UGF5bWVudCA9IDUwMDA7CiRwYXltZW50VG90YWwgPSAwOwokZXh0cmFQYXltZW50ID0gIngiCgpmb3IgKCRtb250aD0xOyAkbW9udGggPD0gMjA7ICRtb250aCsrKSB7CgkkY3JlZGl0QmFsYW5jZSA9ICgkY3JlZGl0QmFsYW5jZSAqICRjcmVkaXRQZXJjZW50KSArICRjcmVkaXRDb21pc3Npb24gLSAkbW9udGhseVBheW1lbnQ7CgkkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRtb250aGx5UGF5bWVudDsKCWVjaG8gInskbW9udGh9INC80LXRgdGP0YYg0YHQv9GD0YHRgtGPOiDQtNC+0LvQsyA9IHskY3JlZGl0QmFsYW5jZX0g0YDRg9CxLCDQstGL0L/Qu9Cw0YfQtdC90L4g0LLRgdC10LPQviB7JHBheW1lbnRUb3RhbH0g0YDRg9CxLlxuIjsKCglpZiAoJGNyZWRpdEJhbGFuY2UgPCA1MDAwKSB7CgkJJGNyZWRpdEJhbGFuY2UgPSAkcGF5bWVudFRvdGFsIC0gIngiOwoJCWVjaG8gItChINC80LXQvdGPICDRhdCy0LDRgtC40YIhXG4iOwoJCWJyZWFrOyAKCX0KfQo/Pg==