<?php
$monthly = 5000;
$credit = 39999;
$penalty = 7777;
function calculatePayments($credit, $monthly, $percent, $service, $paymentTotal) {
for ($month = 1; $credit != 0; $month ++) {
$compulsory = ( $credit * $percent ) + $service;
$payment = min($compulsory, $monthly); $credit = $compulsory - $payment;
$paymentTotal = $paymentTotal + $payment;
}
return $paymentTotal;
}
$alfaBankTotal = calculatePayments($credit, $monthly, 1.04, 500, 0);
$privatBankTotal = calculatePayments($credit, $monthly, 1.03, 1000, 0);
$homeCreditTotal = calculatePayments($credit + $penalty, $monthly, 1.02, 0, 0);
echo "AlfaBank = $alfaBankTotal\n";
echo "PrivatBank = $privatBankTotal\n";
echo "HomeCreditBank = $homeCreditTotal\n";
?>
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwoKJG1vbnRobHkgPSA1MDAwOwokY3JlZGl0ID0gMzk5OTk7CiRwZW5hbHR5ID0gNzc3NzsKIApmdW5jdGlvbiBjYWxjdWxhdGVQYXltZW50cygkY3JlZGl0LCAkbW9udGhseSwgJHBlcmNlbnQsICRzZXJ2aWNlLCAkcGF5bWVudFRvdGFsKSB7CiAKCWZvciAoJG1vbnRoID0gMTsgJGNyZWRpdCAhPSAwOyAkbW9udGggKyspIHsKIAoJCSRjb21wdWxzb3J5ID0gKCAkY3JlZGl0ICogJHBlcmNlbnQgKSArICRzZXJ2aWNlOwoJCSRwYXltZW50ID0gbWluKCRjb21wdWxzb3J5LCAkbW9udGhseSk7CgkJJGNyZWRpdCA9ICRjb21wdWxzb3J5IC0gJHBheW1lbnQ7CgkJJHBheW1lbnRUb3RhbCA9ICRwYXltZW50VG90YWwgKyAkcGF5bWVudDsKCX0KCQogICAgcmV0dXJuICRwYXltZW50VG90YWw7Cn0KIAokYWxmYUJhbmtUb3RhbCA9IGNhbGN1bGF0ZVBheW1lbnRzKCRjcmVkaXQsICRtb250aGx5LCAxLjA0LCA1MDAsIDApOwokcHJpdmF0QmFua1RvdGFsID0gY2FsY3VsYXRlUGF5bWVudHMo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