<?php
function countCyka($creditSum, $percent, $servicePayment, $payout, $firstPay){
//echo "{$creditSum}, {$firstPay}\n";
$creditSum = $creditSum + $firstPay;
//echo "{$creditSum}\n";
$totalPay = 0;
for ($month=0; $month <=20; $month++){
$creditSum = $creditSum + ($creditSum * $percent) + $servicePayment;
if($creditSum < $payout){
$payout = $creditSum;
$creditSum = $creditSum - $payout;
$totalPay = $totalPay + $payout;
//echo "Ура, я расплатился! Потратил {$totalPay} рублей на эту срань!\n";
break;
} else {
$creditSum = $creditSum - $payout;
$totalPay = $totalPay + $payout;
//echo "Выплатил уже {$totalPay}.\n";
}
}
return $totalPay;
}
$homoCreditTotal = countCyka(39999, 0.04, 500, 5000, 0);
$softBankTotal = countCyka(39999, 0.03, 1000, 5000, 0);
$strawberryBankTotal = countCyka(39999, 0.02, 0, 5000, 7777);
echo "Homocredit: {$homoCreditTotal}.\n";
echo "SoftBank: {$softBankTotal}.\n";
echo "StrawberryBank: {$strawberryBankTotal}.\n";
?>
// your code goes here
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBjb3VudEN5a2EoJGNyZWRpdFN1bSwgJHBlcmNlbnQsICRzZXJ2aWNlUGF5bWVudCwgJHBheW91dCwgJGZpcnN0UGF5KXsKCS8vZWNobyAieyRjcmVkaXRTdW19LCB7JGZpcnN0UGF5fVxuIjsKICAgICRjcmVkaXRTdW0gPSAkY3JlZGl0U3VtICsgJGZpcnN0UGF5OwogICAgLy9lY2hvICJ7JGNyZWRpdFN1bX1cbiI7CgkkdG90YWxQYXkgPSAwOwoJZm9yICgkbW9udGg9MDsgJG1vbnRoIDw9MjA7ICRtb250aCsrKXsKCSRjcmVkaXRTdW0gPSAkY3JlZGl0U3VtICsgKCRjcmVkaXRTdW0gKiAkcGVyY2VudCkgKyAkc2VydmljZVBheW1lbnQ7CgkgaWYoJGNyZWRpdFN1bSA8ICRwYXlvdXQpewoJIAkkcGF5b3V0ID0gJGNyZWRpdFN1bTsKCSAJJG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