<?php
function countTotalPayment ($creditDebt, $percent, $serviceFee, $monthlyPayment) {
for ($months = 2, $paymentTotal = 0; $months <= 20; $months ++) {
if ($months == 2) {
$creditDebt = $creditDebt + 7777;
}
$creditDebt = ($creditDebt * $percent) + $serviceFee - $monthlyPayment;
$paymentTotal = $paymentTotal + $monthlyPayment;
if (($creditDebt * $percent) + $serviceFee < $monthlyPayment) {
$paymentTotal = $paymentTotal + ($creditDebt * $percent) + $serviceFee;
$months++;
break;
}
}
return $paymentTotal;
}
$creditSum = 40000;
$payout = 5000;
$homoCreditTotal = countTotalPayment ($creditSum, 1.04, 500, $payout);
$softbankTotal = countTotalPayment ($creditSum, 1.03, 1000, $payout);
$strawberryBankTotal = countTotalPayment ($creditSum, 1.02, 0, $payout);
echo "HomoCredit: {$homoCreditTotal} \n";
echo "Softbank: {$softbankTotal} \n";
echo "StrawberryBank: {$strawberryBankTotal} \n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwogCmZ1bmN0aW9uIGNvdW50VG90YWxQYXltZW50ICgkY3JlZGl0RGVidCwgJHBlcmNlbnQsICRzZXJ2aWNlRmVlLCAkbW9udGhseVBheW1lbnQpIHsKICAgIGZvciAoJG1vbnRocyA9IDIsICRwYXltZW50VG90YWwgPSAwOyAkbW9udGhzIDw9IDIwOyAkbW9udGhzICsrKSB7CiAgICBpZiAoJG1vbnRocyA9PSAyKSB7CiAgICAgICAgJGNyZWRpdERlYnQgPSAkY3JlZGl0RGVidCArIDc3Nzc7Cn0KICAgICAgICAkY3JlZGl0RGVidCA9ICgkY3JlZGl0RGVidCAqICRwZXJjZW50KSArICRzZXJ2aWNlRmVlIC0gJG1vbnRobHlQYXltZW50OwogICAgICAgICRwYXltZW50VG90YWwgPSAkcGF5bWVudFRvdGFsICsgJG1vbnRobHlQYXltZW50OwogICAgaWYgKCgkY3JlZGl0RGVidCAqICRwZXJjZW50KSArICRzZXJ2aWNlRmVlIDwgJG1vbnRobHlQYXltZW50KSB7CiAgICAg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