<?php
function calcCredit( $creditSum , $firstPayment , $monthlyPayment , $percent , $payout ) {
$payment = $creditSum + $firstPayment ;
echo "paymet = {$payment} \n " ;
$totalPayout = 0 ;
for ( ;; ) {
echo "paymnet = $payment " ;
echo "payout = $payout " ;
$payment = $payment * $pecent + $monthlyPayment ;
if ( $payment >= $payout ) {
$payment -= $payout ;
$totalPayout += $payout ;
} else {
$totalPayout += $payment ;
break ;
}
}
return $totalPayout ;
}
$creditSum = 40000 ;
$payout = 5000 ;
$homoCretidTotal = calcCredit( $creditSum , 0 , 500 , 1.04 , $payout ) ;
$softBankTotal = calcCredit( $creditSum , 0 , 1000 , 1.03 , $payout ) ;
$strawberryBankTotal = calcCredit( $creditSum , 7777 , 0 , 1.02 , $payout ) ;
echo "homoCredit = {$homoCretidTotal} \n " ;
echo "softBank = {$softBankTotal} \n " ;
echo "strawberryBank = {$strawberryBankTotal} \n " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBjYWxjQ3JlZGl0KCRjcmVkaXRTdW0sICRmaXJzdFBheW1lbnQsICRtb250aGx5UGF5bWVudCwgJHBlcmNlbnQsICRwYXlvdXQpIHsKCSRwYXltZW50ID0gJGNyZWRpdFN1bSArICRmaXJzdFBheW1lbnQ7CgllY2hvICJwYXltZXQgPSB7JHBheW1lbnR9XG4iOwoJJHRvdGFsUGF5b3V0ID0gMDsKCQoJZm9yICg7OykgewoJCWVjaG8gInBheW1uZXQgPSAkcGF5bWVudCI7CgkJZWNobyAicGF5b3V0ID0gJHBheW91dCI7CgkJJHBheW1lbnQgPSAkcGF5bWVudCAqICRwZWNlbnQgKyAkbW9udGhseVBheW1lbnQ7CgkJaWYgKCRwYXltZW50ID49ICRwYXlvdXQpIHsKCQkJJHBheW1lbnQgLT0gJHBheW91dDsKCQkJJHRvdGFsUGF5b3V0ICs9ICRwYXlvdXQ7CgkJfSBlbHNlIHsKCQkJJHRvdGFsUGF5b3V0ICs9ICRwYXltZW50OwoJCQl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