<?php
function paymentSum($sum, $payout, $percent, $commission) {
$paymentTotal=0;
for ($i=1; $i>0; $i++) {
$sum = $sum + $sum * $percent/100 + $commission;
if ($sum > $payout) {
$sum = $sum - $payout;
$paymentTotal = $paymentTotal + $payout;
} elseif ($sum < $payout) {
$payout = $sum;
$paymentTotal = $paymentTotal + $payout;
break;
}
}
return $paymentTotal;
}
$homoCreditTotal = paymentSum(39999, 5000, 4, 500);
$softBankTotal = paymentSum(39999, 5000, 3,1000);
$strawberryBankTotal = paymentSum(39999, 5000, 2, 0) + 7777;
echo"1 - $homoCreditTotal рублей\n";
echo"2 - $softBankTotal рублей\n";
echo"3 - $strawberryBankTotal рублей\n";
?>
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwogCmZ1bmN0aW9uIHBheW1lbnRTdW0oJHN1bSwgJHBheW91dCwgJHBlcmNlbnQsICRjb21taXNzaW9uKSB7CgkkcGF5bWVudFRvdGFsPTA7Cglmb3IgKCRpPTE7ICRpPjA7ICRpKyspIHsKCQkkc3VtID0gJHN1bSArICRzdW0gKiAkcGVyY2VudC8xMDAgKyAkY29tbWlzc2lvbjsKCQlpZiAoJHN1bSA+ICRwYXlvdXQpIHsKCQkJJHN1bSA9ICRzdW0gLSAkcGF5b3V0OwoJCQkkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRwYXlvdXQ7CgkJfSBlbHNlaWYgKCRzdW0gPCAkcGF5b3V0KSB7CgkJCSRwYXlvdXQgPSAkc3VtOwoJCQkkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRwYXlvdXQ7CgkJCWJyZWFrOwoJCX0KCX0KCXJldHVybiAkcGF5bWVudFRvdGFsOwp9CiAKJGhvbW9DcmVkaXRUb3RhbCA9IHBheW1lbnRTdW0oMzk5OTksIDUwMDAsIDQsIDUwMCk7CiRzb2Z0QmFua1RvdGFsID0gcGF5bWVudFN1bSgzOTk5OSwgNTAwMCwgMywxMDAwKTsKJHN0cmF3YmVycnlCYW5rVG90YWwgPSBwYXltZW50U3VtKDM5OTk5LCA1MDAwLCAyLCAwKSArIDc3Nzc7CiAKZWNobyIxIC0gJGhvbW9DcmVkaXRUb3RhbCDRgNGD0LHQu9C10LlcbiI7CmVjaG8iMiAtICRzb2Z0QmFua1RvdGFsINGA0YPQsdC70LXQuVxuIjsKZWNobyIzIC0gJHN0cmF3YmVycnlCYW5rVG90YWwg0YDRg9Cx0LvQtdC5XG4iOwogCj8+