<?php
function countLoanCost($percent, $servicePayout, $openPayout, $creditSum, $maxPayout){
$creditBalance = $creditSum + $openPayout;
$paymentTotal = 0;
for ( $month=1; $month <= 100000; $month++ ) {
$creditBalance = round(($creditBalance * $percent) + $servicePayout, 2); $anonPays = min($maxPayout, $creditBalance); $creditBalance -= $anonPays;
$paymentTotal += $anonPays;
if ($creditBalance == 0) {
break;
}
}
return $paymentTotal;
}
$creditSum = 39999;
$maxPayout= 5000;
$homoCreditTotal = countLoanCost(1.04, 500, 0, $creditSum, $maxPayout);
$softBankTotal = countLoanCost(1.03, 1000, 0, $creditSum, $maxPayout);
$strawberryBankTotal = countLoanCost(1.02, 0, 7777, $creditSum, $maxPayout);
echo "HomoCredit : {$homoCreditTotal} руб.\n";
echo "SoftBank : {$softBankTotal} руб.\n";
echo "StrawberryBank : {$strawberryBankTotal} руб.\n";
?>
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcgKC0xKTsKIApmdW5jdGlvbiBjb3VudExvYW5Db3N0KCRwZXJjZW50LCAkc2VydmljZVBheW91dCwgJG9wZW5QYXlvdXQsICRjcmVkaXRTdW0sICRtYXhQYXlvdXQpewogICAgJGNyZWRpdEJhbGFuY2UgPSAkY3JlZGl0U3VtICsgJG9wZW5QYXlvdXQ7CiAgICAkcGF5bWVudFRvdGFsID0gMDsKICAgICAgICBmb3IgKCAkbW9udGg9MTsgJG1vbnRoIDw9IDEwMDAwMDsgJG1vbnRoKysgKSB7CiAgICAgICAgICAgICRjcmVkaXRCYWxhbmNlID0gcm91bmQoKCRjcmVkaXRCYWxhbmNlICogJHBlcmNlbnQpICsgJHNlcnZpY2VQYXlvdXQsIDIpOwogICAgICAgICAgICAkYW5vblBheXMgPSBtaW4oJG1heFBheW91dCwgJGNyZWRpdEJhbGFuY2UpOwogICAgICAgICAgICAkY3JlZGl0QmFsYW5jZSAtPSAkYW5vblBheXM7CiAgICAgICAgICAgICRwYXltZW50VG90YWwgKz0gJGFub25QYXlzOwogICAgICAgICAgICAgIC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