<?php
function credit($summa, $persent, $plusVMesyac, $nachalniyVznos, $plataVMes)
{
$vsyaSumma = $summa + $nachalniyVznos;
$skolkoViplatil = 0;
for ($i = 1; $i <= 100; $i++) {
$vsyaSumma = ($vsyaSumma * $persent + $plusVMesyac);
if ($vsyaSumma > $plataVMes) {
$vsyaSumma = $vsyaSumma - $plataVMes;
} else {
$plataVMes = $vsyaSumma;
$vsyaSumma = $vsyaSumma - $plataVMes;
}
$skolkoViplatil = $skolkoViplatil + $plataVMes;
if ($vsyaSumma <= 0) {
return $skolkoViplatil;
break;
}
}
}
$creditsum = 39999;
$payount = 5000;
$homoCreditTotal = credit($creditsum, 1.04, 500, 0, $payount);
$softBankTotal = credit($creditsum, 1.03, 1000, 0, $payount);
$strawberryBankTotal = credit($creditsum, 1.02, 0, 7777, $payount);
echo "homoCredit: {$homoCreditTotal} рублей \n";
echo "softBankTotal: {$softBankTotal} рублей\n";
echo "strawberryBankTotal: {$strawberryBankTotal} рублей \n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBjcmVkaXQoJHN1bW1hLCAkcGVyc2VudCwgJHBsdXNWTWVzeWFjLCAkbmFjaGFsbml5Vnpub3MsICRwbGF0YVZNZXMpCnsKICAgIAogICAgJHZzeWFTdW1tYSAgICAgID0gJHN1bW1hICsgJG5hY2hhbG5peVZ6bm9zOwogICAgJHNrb2xrb1ZpcGxhdGlsID0gMDsKICAgIGZvciAoJGkgPSAxOyAkaSA8PSAxMDA7ICRpKyspIHsKICAgICAgICAkdnN5YVN1bW1hID0gKCR2c3lhU3VtbWEgKiAkcGVyc2VudCArICRwbHVzVk1lc3lhYyk7CiAgICAgICAgCiAgICAgICAgaWYgKCR2c3lhU3VtbWEgPiAkcGxhdGFWTWVzKSB7CiAgICAgICAgICAgICR2c3lhU3VtbWEgPSAkdnN5YVN1bW1hIC0gJHBsYXRhVk1lczsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAkcGxhdGFWTWVzID0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