<?php
function pay($creditSum, $payout, $percent, $servicePay, $opening) {
$paymentTotal = 0;
$creditSum = $creditSum + $opening;
for ($i = 0; $i < 30; $i++) {
$debt = ($creditSum / 100 * (100 + $percent)) + $servicePay;
if ($debt <= $payout) {
$paymentTotal = $paymentTotal + $debt;
break;
} else {
$creditSum = $debt - $payout;
$paymentTotal = $paymentTotal + $payout;
}
}
return $paymentTotal;
}
$creditSum = 40000;
$payout = 5000;
$homoCredit = pay($creditSum, $payout, 4, 500, 0);
$softbank = pay($creditSum, $payout, 3, 1000, 0);
$strawberryBank = pay($creditSum, $payout, 2, 0, 7777);
echo "homoCredit: {$homoCredit} руб.\n";
echo "softbank: {$softbank} руб.\n";
echo "strawberryBank: {$strawberryBank} руб.\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBwYXkoJGNyZWRpdFN1bSwgJHBheW91dCwgJHBlcmNlbnQsICRzZXJ2aWNlUGF5LCAkb3BlbmluZykgewoJJHBheW1lbnRUb3RhbCA9IDA7CgkkY3JlZGl0U3VtID0gJGNyZWRpdFN1bSArICRvcGVuaW5nOwoJZm9yICgkaSA9IDA7ICRpIDwgMzA7ICRpKyspIHsKCQkkZGVidCA9ICgkY3JlZGl0U3VtIC8gMTAwICogKDEwMCArICRwZXJjZW50KSkgKyAkc2VydmljZVBheTsKCQlpZiAoJGRlYnQgPD0gJHBheW91dCkgewoJCQkkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRkZWJ0OwoJCQlicmVhazsKCQl9IGVsc2UgewoJCQkkY3JlZGl0U3VtID0gJGRlYnQgLSAkcGF5b3V0OwoJCSAgICAkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRwYXlvdXQ7CgkJfQoJfQoJcmV0dXJuICRwYXltZW50VG90YWw7Cn0KCiRjcmVkaXRTdW0gID0gNDAwMDA7CiRwYXlvdXQgPSA1MDAwOwoKCiRob21vQ3JlZGl0ID0gcGF5KCRjcmVk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