<?php
header ( "Content-Type: text/plain; charset=utf-8" ) ;
function getTotalAmountOfPayments( $creditBalance , $monthlyPayment , $percent , $servicePayment , $paymentTotal ) {
do {
$creditBalance = ( $creditBalance * $percent ) + $servicePayment ;
if ( $creditBalance <= $monthlyPayment ) {
$monthlyPayment = $creditBalance ;
}
$creditBalance -= $monthlyPayment ;
$paymentTotal += $monthlyPayment ;
} while ( $creditBalance > 0 ) ;
return $paymentTotal ;
}
$creditBalance = 39999 ;
$monthlyPayment = 5000 ;
$homoCreditTotal = getTotalAmountOfPayments( $creditBalance , $monthlyPayment , 1.04 , 500 , 0 ) ;
$softBankTotal = getTotalAmountOfPayments( $creditBalance , $monthlyPayment , 1.03 , 1000 , 0 ) ;
$strawberryBankCreditTotal = getTotalAmountOfPayments( $creditBalance + 7777 , $monthlyPayment , 1.02 , 0 , 0 ) ;
echo "Сумма выплат в первом банке - {$homoCreditTotal} руб. \n " ;
echo "Сумма выплат во втором банке - {$softBankTotal} руб. \n " ;
echo "Сумма выплат в третьем банке - {$strawberryBankCreditTotal} руб. \n " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CmhlYWRlcigiQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PXV0Zi04Iik7CgpmdW5jdGlvbiBnZXRUb3RhbEFtb3VudE9mUGF5bWVudHMoJGNyZWRpdEJhbGFuY2UsICRtb250aGx5UGF5bWVudCwgJHBlcmNlbnQsICRzZXJ2aWNlUGF5bWVudCwgJHBheW1lbnRUb3RhbCkgewogICAgZG8gewogICAgICAgICRjcmVkaXRCYWxhbmNlID0gKCAkY3JlZGl0QmFsYW5jZSAqICRwZXJjZW50ICkgKyAkc2VydmljZVBheW1lbnQ7CgogICAgICAgIGlmICgkY3JlZGl0QmFsYW5jZSA8PSAkbW9udGhseVBheW1lbnQpIHsKICAgICAgICAgICAgJG1vbnRobHlQYXltZW50ID0gJGNyZWRpdEJhbGFuY2U7CiAgICAgICAgfQogICAgICAgICRjc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