<?php
function ioanCalc ($creditSum, $percent, $comission, $firstPay, $payout){
$totalPay = 0;
$percentSum = $percent * ($creditSum + $firstPay)/100;
for ($i = 0; $creditSum > 0; $i++) {
$creditSum = $creditSum + $comission + $percentSum;
if ($creditSum < $payout) {
$payout = $creditSum;
}
$creditSum = $creditSum - $payout;
$totalPay = $totalPay + $payout;
}
return $totalPay;
}
$creditSum = 39999;
$payout = 5000;
$totalPay = 0;
$homoCreditTotal = ioanCalc($creditSum, 4, 500, 0, $payout);
$softbankTotal = ioanCalc($creditSum, 3, 1000, 0, $payout);
$strawberrybankTotal = ioanCalc($creditSum, 2, 0, 7777, $payout);
echo "HomoCredit: {$homoCreditTotal}\n";
echo "Softbank: {$softbankTotal}\n";
echo "StrawberryBank: {$strawberrybankTotal}\n";
?>
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBpb2FuQ2FsYyAoJGNyZWRpdFN1bSwgJHBlcmNlbnQsICRjb21pc3Npb24sICRmaXJzdFBheSwgJHBheW91dCl7CgkKCSR0b3RhbFBheSA9IDA7CiAgICAkcGVyY2VudFN1bSA9ICAkcGVyY2VudCAqICgkY3JlZGl0U3VtICsgJGZpcnN0UGF5KS8xMDA7CgoJZm9yICgkaSA9IDA7ICRjcmVkaXRTdW0gPiAwOyAkaSsrKSB7CgkJJGNyZWRpdFN1bSA9ICRjcmVkaXRTdW0gKyAkY29taXNzaW9uICsgJHBlcmNlbnRTdW07CgkJaWYgKCRjcmVkaXRTdW0gPCAkcGF5b3V0KSB7CgkJCSRwYXlvdXQgPSAkY3JlZGl0U3VtOwoJCX0KCQkkY3JlZGl0U3VtID0gJGNyZWRpdFN1bSAtICRwYXlvdXQ7CgkJJHRvdGFsUGF5ID0gJHRvdGFsUGF5ICsgJHBheW91dDsKCX0KCXJldHVybiAkdG90YWxQYXk7Cn0KCiRjcmVkaXRTdW0gPSAzOTk5OTsKJHBheW91dCA9IDUwMDA7CiR0b3RhbFBheSA9IDA7CgokaG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