<?php
function calcCredit($creditSum, $payout, $percent, $comissionPayment, $openPayment, $paymentTotal = 0) {
$creditSum += $openPayment;
for($month = 1; $creditSum > 0; $month ++) {
$creditSum = ($creditSum * $percent) + $comissionPayment;
if($creditSum < $payout) {
$payout = $creditSum;
}
$creditSum -= $payout;
$paymentTotal += $payout;
}
return $paymentTotal;
}
$homoCreditTotal = calcCredit(39999, 5000, 1.04, 500, 0);
$softBankTotal = calcCredit(39999, 5000, 1.03, 1000, 0);
$strawberryBankTotal = calcCredit(39999, 5000, 1.02, 0, 7777);
echo "homoCredit: {$homoCreditTotal} руб.\n";
echo "softBank: {$softBankTotal} руб.\n";
echo "strawberryBank: {$strawberryBankTotal} руб.\n";
?>
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKZnVuY3Rpb24gY2FsY0NyZWRpdCgkY3JlZGl0U3VtLCAkcGF5b3V0LCAkcGVyY2VudCwgJGNvbWlzc2lvblBheW1lbnQsICRvcGVuUGF5bWVudCwgJHBheW1lbnRUb3RhbCA9IDApIHsKCSRjcmVkaXRTdW0gKz0gJG9wZW5QYXltZW50OwoJZm9yKCRtb250aCA9IDE7ICRjcmVkaXRTdW0gPiAwOyAkbW9udGggKyspIHsKCQkkY3JlZGl0U3VtID0gKCRjcmVkaXRTdW0gKiAkcGVyY2VudCkgKyAkY29taXNzaW9uUGF5bWVudDsKCQlpZigkY3JlZGl0U3VtIDwgJHBheW91dCkgewoJCQkkcGF5b3V0ID0gJGNyZWRpdFN1bTsKCQl9CgkJJGNyZWRpdFN1bSAtPSAkcGF5b3V0OwoJCSRwYXltZW50VG90YWwgKz0gJHBheW91dDsKCQl9CglyZXR1cm4gJHBheW1lbnRUb3RhbDsKfQoKJGhvbW9DcmVkaXRUb3RhbCA9IGNhbGNDcmVkaXQoMzk5OTksIDUwMDAsIDEuMDQsIDUwMCwgMCk7CiRzb2Z0QmFua1RvdGFsID0gY2FsY0N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