<?php
header("Content-Type: text/plain; charset=utf-8");
$monthlyPayment = 5000;
$creditSum = 39999;
function getTotalAmountOfPayments($creditBalance, $paymentTotal, $percent, $servicePayment, $monthlyPayment) {
do {
$creditBalance = ( $creditBalance * $percent ) + $servicePayment;
if ($creditBalance <= $monthlyPayment) {
$monthlyPayment = $creditBalance;
}
$creditBalance -= $monthlyPayment;
$paymentTotal += $monthlyPayment;
} while ($creditBalance > 0);
return $paymentTotal;
}
$homoCreditTotal = getTotalAmountOfPayments($creditSum, 0, 1.04, 500, $monthlyPayment);
$softBankTotal = getTotalAmountOfPayments($creditSum, 0, 1.03, 1000, $monthlyPayment);
$strawberryBankCreditTotal = getTotalAmountOfPayments($creditSum, 7777, 1.02, 0, $monthlyPayment);
echo "Сумма выплат в первом банке - {$homoCreditTotal} \n";
echo "Сумма выплат во втором банке - {$softBankTotal} \n";
echo "Сумма выплат в третьем банке - {$strawberryBankCreditTotal} \n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CmhlYWRlcigiQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PXV0Zi04Iik7CgokbW9udGhseVBheW1lbnQgPSA1MDAwOwokY3JlZGl0U3VtID0gMzk5OTk7CgpmdW5jdGlvbiBnZXRUb3RhbEFtb3VudE9mUGF5bWVudHMoJGNyZWRpdEJhbGFuY2UsICRwYXltZW50VG90YWwsICRwZXJjZW50LCAkc2VydmljZVBheW1lbnQsICRtb250aGx5UGF5bWVudCkgewogICAgZG8gewogICAgICAgICRjcmVkaXRCYWxhbmNlID0gKCAkY3JlZGl0QmFsYW5jZSAqICRwZXJjZW50ICkgKyAkc2VydmljZVBheW1lbnQ7CgogICAgICAgIGlmICgkY3JlZGl0QmFsYW5jZSA8PSAkbW9udGhseVBheW1lbnQpIHsKICAgICAgICAgICAgJG1vbnRobHlQYXltZW50ID0gJGNyZWRpdEJhbGFuY2U7CiAgICAgICAgfQogICAgICAgICRjcmVkaXRCYWxhbmNlIC09ICR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