<?php
function credit($percent, $service, $oneTimePay) { //Процентная ставка, ежемесячный платёж, единоразовый платёж
$creditBalance = 39999; //сумма кредита
$paymentTotal = 0; //общая сумма выплат
$mountlyPayment = 5000; //ежемесячная выплата
$creditBalance = $creditBalance + $oneTimePay;
for ($mounth = 0; $creditBalance > 0; $mounth++) {
$creditBalance = ($creditBalance * $percent) + $service;
if ($creditBalance < $mountlyPayment) { //проверка не больше ли месячный платёж остатка по кредиту, чтобы банк не залез в минус
$mountlyPayment = $creditBalance;
}
$creditBalance = $creditBalance - $mountlyPayment;
$paymentTotal = $paymentTotal + $mountlyPayment;
}
return $paymentTotal; //возврат общей суммы выплат
}
$homoCreditBank = credit(1.04, 500, 0);
$softBank = credit(1.03, 1000, 0);
$strawberryBank = credit(1.02, 0, 7777);
echo "HomoCreditBank: {$homoCreditBank}\n";
echo "SoftBank: {$softBank}\n";
echo "StrawberryBank: {$strawberryBank}\n";
?>
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBjcmVkaXQoJHBlcmNlbnQsICRzZXJ2aWNlLCAkb25lVGltZVBheSkgeyAvL9Cf0YDQvtGG0LXQvdGC0L3QsNGPINGB0YLQsNCy0LrQsCwg0LXQttC10LzQtdGB0Y/Rh9C90YvQuSDQv9C70LDRgtGR0LYsINC10LTQuNC90L7RgNCw0LfQvtCy0YvQuSDQv9C70LDRgtGR0LYKCSRjcmVkaXRCYWxhbmNlID0gMzk5OTk7IC8v0YHRg9C80LzQsCDQutGA0LXQtNC40YLQsAoJJHBheW1lbnRUb3RhbCA9IDA7IC8v0L7QsdGJ0LDRjyDRgdGD0LzQvNCwINCy0YvQv9C70LDRggoJJG1vdW50bHlQYXltZW50ID0gNTAwMDsgLy/QtdC20LXQvNC10YHRj9GH0L3QsNGPINCy0YvQv9C70LDRgtCwCgkKCSRjcmVkaXRCYWxhbmNlID0gJGNyZWRpdEJhbGFuY2UgKyAkb25lVGltZVBheTsgCgkgCglmb3IgKCRtb3VudG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