<?php
function getSum ($percent, $tax, $account, $creditSum, $payout) {
$paymentTotal = 0;
$creditSum = $creditSum + $account;
if (($creditSum * ($percent - 1) + $tax) >= $payout) {
$paymentTotal = 'Бесконечно';
}
else {
for ( ; ; ) {
$creditBalance = $creditSum * $percent - $payout + $tax;
$paymentTotal += $payout;
$creditSum = $creditBalance;
if ($creditBalance < 0) {
$paymentTotal += $creditBalance;
$paymentTotal = round($paymentTotal,2); break;
}
}
}
return $paymentTotal;
}
$creditSum = 39999;
$payout = 5000;
$homoCreditBank = getSum (1.04, 500, 0, $creditSum, $payout);
$softBank = getSum (1.03, 1000, 0, $creditSum, $payout);
$StrawberryBankTotal = getSum (1.02, 0, 7777, $creditSum, $payout);
echo "homoCreditBank $homoCreditBank руб \n";
echo "SoftBank $softBank руб \n";
echo "StrawberryBankTotal $StrawberryBankTotal руб \n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwogCmZ1bmN0aW9uIGdldFN1bSAoJHBlcmNlbnQsICR0YXgsICRhY2NvdW50LCAkY3JlZGl0U3VtLCAkcGF5b3V0KSB7CgkkcGF5bWVudFRvdGFsID0gMDsKCSRjcmVkaXRTdW0gPSAkY3JlZGl0U3VtICsgJGFjY291bnQ7CglpZiAoKCRjcmVkaXRTdW0gKiAoJHBlcmNlbnQgLSAxKSArICR0YXgpID49ICAkcGF5b3V0KSB7CgkJJHBheW1lbnRUb3RhbCA9ICfQkdC10YHQutC+0L3QtdGH0L3Qvic7CgkJfQoJCWVsc2UgewoJCQlmb3IgKCA7IDsgKSB7CgkJCQkkY3JlZGl0QmFsYW5jZSA9ICRjcmVkaXRTdW0gKiAkcGVyY2VudCAtICRwYXlvdXQgKyAkdGF4OwoJCQkJJHBheW1lbnRUb3RhbCArPSAgJHBheW91dDsKCQkJCSRjcmVkaXRTdW0gPSAkY3JlZGl0QmFsYW5jZTsKCQkJCWlmICgkY3JlZGl0QmFsYW5jZSA8IDApIHsKCQkJCQkkcGF5bWVudFRvdGFsICs9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