<?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 = 1000;
$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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