<?php
function getBalance($creditBalance, $monthlyPayment, $percent, $servicePayment, $paymentTotal) {
for ($month = 1; $month <= 20; $month ++) {
$creditBalance = ( $creditBalance * $percent ) + $servicePayment;
if ($creditBalance < $monthlyPayment) {
$monthlyPayment = $creditBalance;
}
$paymentTotal = $paymentTotal + $monthlyPayment;
$creditBalance -= $monthlyPayment;
if ($creditBalance <= 0) {
break;
}
}
return $paymentTotal;
}
$creditBalance = 39999; /* Долг анона перед банком */
$monthlyPayment = 5000; /* Анон платит 5000 р в месяц, это все, что ему дает мама на завтраки */
$homoCreditTotal = getBalance($creditBalance, $monthlyPayment, 1.04, 500, 0);
$softbankTotal = getBalance($creditBalance, $monthlyPayment, 1.03, 1000, 0);
$strawberryBankTotal = getBalance($creditBalance + 7777, $monthlyPayment, 1.02, 0, 0);
echo "homoCredit: {$homoCreditTotal}\n";
echo "softbank: {$softbankTotal}\n";
echo "strawberryBank: {$strawberryBankTotal}\n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwoKZnVuY3Rpb24gZ2V0QmFsYW5jZSgkY3JlZGl0QmFsYW5jZSwgJG1vbnRobHlQYXltZW50LCAkcGVyY2VudCwgJHNlcnZpY2VQYXltZW50LCAkcGF5bWVudFRvdGFsKSB7CiAKZm9yICgkbW9udGggPSAxOyAkbW9udGggPD0gMjA7ICRtb250aCArKykgewogCgkkY3JlZGl0QmFsYW5jZSA9ICggJGNyZWRpdEJhbGFuY2UgKiAkcGVyY2VudCApICsgJHNlcnZpY2VQYXltZW50OwogCglpZiAoJGNyZWRpdEJhbGFuY2UgPCAkbW9udGhseVBheW1lbnQpIHsKCQkkbW9udGhseVBheW1lbnQgPSAkY3JlZGl0QmFsYW5jZTsKCX0KCSRwYXltZW50VG90YWwgPSAkcGF5bWVudFRvdGFsICsgJG1vbnRobHlQYXltZW50OwoJJGNyZWRpdEJhbGFuY2UgLT0gJG1vbnRobHlQYXltZW50OwogICAgCiAgICBpZiAoJGNyZWRpdEJhbGFuY2UgP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