<?php
function getCreditTotal( $creditSum , $percent , $comission , $payout , $paymentTotal ) {
for ( $month = 1 ; $month < 20 ; $month ++ ) {
$creditSum = ( $creditSum * $percent ) + $comission - $payout ;
$paymentTotal = $paymentTotal + $payout ;
if ( $creditSum < 0 ) {
break ;
} elseif ( $creditSum < 4000 ) {
$creditSum = ( $creditSum * $percent ) + $comission ;
$paymentTotal = $paymentTotal + $creditSum ;
$creditSum = $creditSum - $creditSum ;
echo "{$month} месяц спустя: долг = {$creditSum} руб, выплачено всего {$paymentTotal} руб. \n " ;
break ;
}
}
return $paymentTotal ;
}
$creditSum = 40000 ;
$payout = 5000 ;
$homoCreditTotal = getCreditTotal( $creditSum , 1.04 , 500 , $payout , 0 ) ;
$softBankTotal = getCreditTotal( $creditSum , 1.03 , 1000 , $payout , 0 ) ;
$strawberryBankTotal = getCreditTotal( $creditSum , 1.02 , 0 , $payout , 0 ) + 7777 ;
echo "homoCredit:{$homoCreditTotal} \n softBank:{$softBankTotal} \n strawberryBank:{$strawberryBankTotal} " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBnZXRDcmVkaXRUb3RhbCgkY3JlZGl0U3VtLCAkcGVyY2VudCwgJGNvbWlzc2lvbiwgJHBheW91dCwgJHBheW1lbnRUb3RhbCkgewoJZm9yICgkbW9udGggPSAxOyAkbW9udGggPCAyMDsgJG1vbnRoICsrKSB7CgkJCgkJJGNyZWRpdFN1bSA9ICggJGNyZWRpdFN1bSAqICRwZXJjZW50ICkgKyAkY29taXNzaW9uIC0gJHBheW91dDsKCQkkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRwYXlvdXQ7CgkgICAgCgkgICAgaWYgKCRjcmVkaXRTdW0gPCAwKSB7CgkgICAgCWJyZWFrOwoJICAgIH0JZWxzZWlmICgkY3JlZGl0U3VtIDwgNDAwMCkgewoJICAgIAkkY3JlZGl0U3VtID0gKCAkY3JlZGl0U3VtICogJHBlcmNlbnQgKSArICR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