<?php
$creditBalance = 40000;
$percent = 1.03;
$servicePayment = 1000;
$monthlyPayment = 5000;
$paymentTotal = 0;
for ($mouth = 1; $creditBalance > 0; $mouth++) {
$creditBalance = ($creditBalance * $percent) + $servicePayment;
$paymentTotal = $paymentTotal + $monthlyPayment;
if ($creditBalance >= $monthlyPayment) {
$creditBalance -= $monthlyPayment;
break;
}
echo "{$mouth} месяц спустя, анон должен банку {$creditBalance}, всего внесено {$paymentTotal}\n";
if ($creditBalance < $monthlyPayment) {
$monthlyPayment=$creditBalance;
break;
}
if ($creditBalance == 0) {
echo"Анон все выплатил";
break;
}
}
?>
ICAgIDw/cGhwCiAgICAgCiAgICBlcnJvcl9yZXBvcnRpbmcoLTEpOwogICAgIAogICAgJGNyZWRpdEJhbGFuY2UgPSA0MDAwMDsgCiAgICAkcGVyY2VudCA9IDEuMDM7IAogICAgJHNlcnZpY2VQYXltZW50ID0gMTAwMDsgCiAgICAkbW9udGhseVBheW1lbnQgPSA1MDAwOyAKICAgICRwYXltZW50VG90YWwgPSAwOyAKICAgICAKICAgIGZvciAoJG1vdXRoID0gMTsgJGNyZWRpdEJhbGFuY2UgPiAwOyAkbW91dGgrKykgewogICAgCSRjcmVkaXRCYWxhbmNlID0gKCRjcmVkaXRCYWxhbmNlICogJHBlcmNlbnQpICsgJHNlcnZpY2VQYXltZW50OwogICAgCSRwYXltZW50VG90YWwgPSAkcGF5bWVudFRvdGFsICsgJG1vbnRobHlQYXltZW50OwogICAgCWlmICgkY3JlZGl0QmFsYW5jZSA+PSAkbW9udGhseVBheW1lbnQpIHsKICAgIAkJJGNyZWRpdEJhbGFuY2UgLT0gJG1vbnRobHlQYXltZW50OwogICAgCQlicmVhazsKICAgIAl9IAogICAgCWVjaG8gInskbW91dGh9INC80LXRgdGP0YYg0YHQv9GD0YHRgtGPLCDQsNC90L7QvSDQtNC+0LvQttC10L0g0LHQsNC90LrRgyB7JGNyZWRpdEJhbGFuY2V9LCDQstGB0LXQs9C+INCy0L3QtdGB0LXQvdC+IHskcGF5bWVudFRvdGFsfVxuIjsKICAgIAlpZiAoJGNyZWRpdEJhbGFuY2UgPCAkbW9udGhseVBheW1lbnQpIHsKICAgIAkJJG1vbnRobHlQYXltZW50PSRjcmVkaXRCYWxhbmNlOwogICAgCQlicmVhazsKICAgIAl9CiAgICAJCiAgICAJaWYgKCRjcmVkaXRCYWxhbmNlID09IDApIHsKICAgIAkJZWNobyLQkNC90L7QvSDQstGB0LUg0LLRi9C/0LvQsNGC0LjQuyI7CiAgICAJCWJyZWFrOwogICAgCX0KCiAgICB9CiAgICAgCiAgICA/Pg==