<?php
function countTotal($sum, $percent, $comm, $also, $pay) {
$total = 0;
$sum += $also;
for (; $sum > 0;) {
$sum = $sum * $percent + $comm;
if ($sum > $pay) {
$total += $pay;
$sum -= $pay;
} else {
$total += $sum;
$sum = 0;
}
}
return $total;
}
$creditSum = 39999;
$payout = 5000;
$homoCreditTotal = countTotal($creditSum, 1.04, 500, 0, $payout);
$softBankTotal = countTotal($creditSum, 1.03, 1000, 0, $payout);
$strawberryBankTotal = countTotal($creditSum, 1.02, 0, 7777, $payout);
echo "homoCreditTotal: {$homoCreditTotal} руб.\n";
echo "softBankTotal: {$softBankTotal} руб.\n";
echo "strawberryBankTotal: {$strawberryBankTotal} руб.\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBjb3VudFRvdGFsKCRzdW0sICRwZXJjZW50LCAkY29tbSwgJGFsc28sICRwYXkpIHsKCSR0b3RhbCA9IDA7Cgkkc3VtICs9ICRhbHNvOwoJZm9yICg7ICRzdW0gPiAwOykgewoJCSRzdW0gPSAkc3VtICogJHBlcmNlbnQgKyAkY29tbTsKCQlpZiAoJHN1bSA+ICRwYXkpIHsKCQkgICAgJHRvdGFsICs9ICRwYXk7CgkJICAgICRzdW0gLT0gJHBheTsKCQl9IGVsc2UgewoJCQkkdG90YWwgKz0gJHN1bTsKCQkJJHN1bSA9IDA7CgkJfQoJfQoJcmV0dXJuICR0b3RhbDsKfQoKJGNyZWRpdFN1bSA9IDM5OTk5OwokcGF5b3V0ID0gNTAwMDsKJGhvbW9DcmVkaXRUb3RhbCA9IGNvdW50VG90YWwoJGNyZWRpdFN1bSwgMS4wNCwgNTAwLCAwLCAkcGF5b3V0KTsKJHNvZnRCYW5rVG90YWwgPSBjb3VudFRvdGFsKCRjcmVkaXRTdW0sIDEuMDMsIDEwMDAsIDAsICRwYXlvdXQpOwokc3RyYXdiZXJyeUJhbmtUb3RhbCA9IGNvdW50VG90YWwoJGNyZWRpdFN1bSwgMS4wMiwgMCwgNzc3NywgJHBheW91dCk7CgplY2hvICJob21vQ3JlZGl0VG90YWw6IHskaG9tb0NyZWRpdFRvdGFsfSDRgNGD0LEuXG4iOwplY2hvICJzb2Z0QmFua1RvdGFsOiB7JHNvZnRCYW5rVG90YWx9INGA0YPQsS5cbiI7CmVjaG8gInN0cmF3YmVycnlCYW5rVG90YWw6IHskc3RyYXdiZXJyeUJhbmtUb3RhbH0g0YDRg9CxLlxuIjs=