<?php
/**
* @param $percent
* @param $commission
* @param $openAccount
* @param $creditBalance
* @param $monthlyPayment
* @return mixed
*/
/*у анона кредит на 40к и на выбор три банка: два с комиссией и процентами, а третий предлагает заплатить за открытие счета один раз и потом на общую сумму будет идти процент. Надо найти выгоднейший банк, при условии, что анон в месяц может платить не более 5к */
function getPayment( $percent , $commission , $openAccount , $creditBalance , $monthlyPayment )
{
$creditBalance = $creditBalance + $openAccount ;
$debt = $creditBalance * $percent + $commission ;
$totalPayed = 0 ;
for ( $i = 0 ; $i <= 24 ; $i ++ ) {
$creditBalance = $debt - $monthlyPayment ;
$totalPayed = $totalPayed + $debt ;
if ( $creditBalance <= 0 ) {
break ;
} elseif ( $debt < $monthlyPayment ) {
$monthlyPayment = $debt ;
echo "{$creditBalance} " ;
}
echo "{$i} Долг - {$debt} \n " ;
echo "Всего - {$totalPayed} \n " ;
}
return $totalPayed ;
}
$creditSum = 39999 ;
$payout = 5000 ;
$homoCreditTotal = getPayment( 1.04 , 500 , 0 , $creditSum , $payout ) ;
$softCreditTotal = getPayment( 1.03 , 1000 , 0 , $creditSum , $payout ) ;
$strawberryCreditTotal = getPayment( 1.02 , 0 , 7777 , $creditSum , $payout ) ;
echo "homoCredit: {$homoCreditTotal} руб.\n " ;
echo "softbank: {$softCreditTotal} руб.\n " ;
echo "strawberryBank: {$strawberryCreditTotal} руб.\n " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Ci8qKgogKiBAcGFyYW0gJHBlcmNlbnQKICogQHBhcmFtICRjb21taXNzaW9uCiAqIEBwYXJhbSAkb3BlbkFjY291bnQKICogQHBhcmFtICRjcmVkaXRCYWxhbmNlCiAqIEBwYXJhbSAkbW9udGhseVBheW1lbnQKICogQHJldHVybiBtaXhlZAogKi8KLyrRgyDQsNC90L7QvdCwINC60YDQtdC00LjRgiDQvdCwIDQw0Log0Lgg0L3QsCDQstGL0LHQvtGAINGC0YDQuCDQsdCw0L3QutCwOiDQtNCy0LAg0YEg0LrQvt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