<?php
function credit( $percent , $comission , $pay , $monthlyPayment , $balance ) {
$balance = $balance * $percent + $pay ;
$month = 0 ;
$paymentTotal = 0 ;
for ( $i = 0 ; $i <= 42 ; $i ++ ) {
$month ++;
$paymentTotal = $paymentTotal + $monthlyPayment ;
$balance = $balance + $comission - $monthlyPayment ;
if ( ( $balance + $comission ) <= $monthlyPayment ) {
$paymentTotal = $paymentTotal + $balance + $comission ;
$month ++;
echo "$month месяцев потребовалось на выплату долга.\n " ;
break ;
}
}
return $paymentTotal ;
}
$HomoCredit = credit( 1.04 , 500 , 0 , 5000 , 40000 ) ;
$Softbank = credit( 1.03 , 1000 , 0 , 5000 , 40000 ) ;
$StrawberryBank = credit( 1.02 , 0 , 7777 , 5000 , 40000 ) ;
echo "HomoCredit:{$HomoCredit} руб.\n " ;
echo "Softbank:{$Softbank} руб.\n " ;
echo "StrawberryBank:{$StrawberryBank} руб.\n " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwoKZnVuY3Rpb24gY3JlZGl0KCRwZXJjZW50LCAkY29taXNzaW9uLCAkcGF5LCAkbW9udGhseVBheW1lbnQsICRiYWxhbmNlKQl7CgkkYmFsYW5jZSA9ICRiYWxhbmNlKiRwZXJjZW50KyRwYXk7CgkkbW9udGg9MDsKCSRwYXltZW50VG90YWw9MDsKCQlmb3IoJGk9MDsgJGk8PTQyOyAkaSsrKQl7CgkJCSRtb250aCsrOwoJCQkkcGF5bWVudFRvdGFsPSRwYXltZW50VG90YWwrJG1vbnRobHlQYXltZW50OwoJCQkkYmFsYW5jZT0kYmFsYW5jZSskY29taXNzaW9uLSRtb250aGx5UGF5bWVudDsKCQkJCWlmKCgkYmFsYW5jZSskY29taXNzaW9uKTw9JG1vbnRobHlQYXltZW50KQl7CgkJCQkJJHBheW1lbnRUb3RhbD0kcGF5bWVudFRvdGFsKyRiYWxhbmNlKyRjb21pc3Npb247CgkJCQkJJG1vbn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