<?php
$period = 20;
$credit = 40000;
$stavka = 0.03;
$payment = 5000;
$komissiya = 1000;
$totalPayment = 0;
$ostatok = 0;
for ($period = 0; $period < 20; $period++){
$credit = $credit + ($credit * $stavka) + $komissiya - $payment;
$totalPayment = $totalPayment + $payment;
echo $credit . " " . $totalPayment . '<br>';
if ($credit - $payment/2 < 0){
$period++;
echo 'Кредит почти погашен! Вам остался последний платеж:';
$lastPayment = $credit + ($credit * $stavka) + $komissiya;
$period++;
$totalPayment += $lastPayment;
echo "<b> $lastPayment </b><br>";
echo "Всего потрачено на кредит за $period мес." . " $totalPayment";
break;
}
}
?>
Cjw/cGhwCmVycm9yX3JlcG9ydGluZygtMSk7CiRwZXJpb2QgPSAyMDsKJGNyZWRpdCA9IDQwMDAwOwokc3RhdmthID0gMC4wMzsKJHBheW1lbnQgPSA1MDAwOwoka29taXNzaXlhID0gMTAwMDsKJHRvdGFsUGF5bWVudCA9IDA7CiRvc3RhdG9rID0gMDsKCmZvciAoJHBlcmlvZCA9IDA7ICRwZXJpb2QgPCAyMDsgJHBlcmlvZCsrKXsKICAkY3JlZGl0ID0gJGNyZWRpdCArICgkY3JlZGl0ICogJHN0YXZrYSkgKyAka29taXNzaXlhIC0gJHBheW1lbnQ7CiAgICAkdG90YWxQYXltZW50ID0gJHRvdGFsUGF5bWVudCArICRwYXltZW50OwogICAgZWNobyAkY3JlZGl0IC4gIiAiIC4gJHRvdGFsUGF5bWVudCAuICc8YnI+JzsKICAgIGlmICgkY3JlZGl0IC0gJHBheW1lbnQvMiA8IDApewogICAgICAgICRwZXJpb2QrKzsKICAgICAgICBlY2hvICfQmtGA0LXQtNC40YIg0L/QvtGH0YLQuCDQv9C+0LPQsNGI0LXQvSEg0JLQsNC8INC+0YHRgtCw0LvRgdGPINC/0L7RgdC70LXQtNC90LjQuSDQv9C70LDRgtC10LY6JzsKICAgICAgICAkbGFzdFBheW1lbnQgPSAkY3JlZGl0ICsgKCRjcmVkaXQgKiAkc3RhdmthKSArICRrb21pc3NpeWE7CiAgICAgICAgJHBlcmlvZCsrOwogICAgICAgICR0b3RhbFBheW1lbnQgKz0gJGxhc3RQYXltZW50OwogICAgICAgIGVjaG8gIjxiPiAkbGFzdFBheW1lbnQgPC9iPjxicj4iOwogICAgICAgIGVjaG8gItCS0YHQtdCz0L4g0L/QvtGC0YDQsNGH0LXQvdC+INC90LAg0LrRgNC10LTQuNGCINC30LAgJHBlcmlvZCDQvNC10YEuIiAuICIgJHRvdGFsUGF5bWVudCI7CiAgICAgICAgYnJlYWs7CiAgICB9Cn0KCj8+