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