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