<?php
$period = 20;
$credit = 4000;
$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/cGhwCmVycm9yX3JlcG9ydGluZygtMSk7CiRwZXJpb2QgPSAyMDsKJGNyZWRpdCA9IDQwMDA7CiRzdGF2a2EgPSAwLjAzOwokcGF5bWVudCA9IDUwMDA7CiRrb21pc3NpeWEgPSAxMDAwOwokdG90YWxQYXltZW50ID0gMDsKJG9zdGF0b2sgPSAwOwoKZm9yICgkcGVyaW9kID0gMDsgJHBlcmlvZCA8IDIwOyAkcGVyaW9kKyspewogICRjcmVkaXQgPSAkY3JlZGl0ICsgKCRjcmVkaXQgKiAkc3RhdmthKSArICRrb21pc3NpeWEgLSAkcGF5bWVudDsKICAgICR0b3RhbFBheW1lbnQgPSAkdG90YWxQYXltZW50ICsgJHBheW1lbnQ7CiAgICBlY2hvICRjcmVkaXQgLiAiICIgLiAkdG90YWxQYXltZW50IC4gJzxicj4nOwogICAgaWYgKCRjcmVkaXQgLSAkcGF5bWVudC8yIDwgMCl7CiAgICAgICAgJHBlcmlvZCsrOwogICAgICAgIGVjaG8gJ9Ca0YDQtdC00LjRgiDQv9C+0YfRgtC4INC/0L7Qs9Cw0YjQtdC9ISDQktCw0Lwg0L7RgdGC0LDQu9GB0Y8g0L/QvtGB0LvQtdC00L3QuNC5INC/0LvQsNGC0LXQtjonOwogICAgICAgICRsYXN0UGF5bWVudCA9ICRjcmVkaXQgKyAoJGNyZWRpdCAqICRzdGF2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