<?php
function pay( $creditSum , $payout , $percent , $servicePay , $opening ) {
$creditSum = $creditSum + $opening ;
for ( $i = 0 ; $i < 30 ; $i ++ ) {
if ( $creditSum <= $payout ) {
$paymentTotal = $paymentTotal + $creditSum ;
break ;
} else {
$creditSum = ( $creditSum / 100 * ( 100 + $percent ) ) + $servicePay - $payout ;
$paymentTotal = $paymentTotal + $payout ;
}
}
return $paymentTotal ;
}
$creditSum = 40000 ;
$payout = 5000 ;
$homoCredit = pay( $creditSum , $payout , 4 , 500 , 0 ) ;
$softbank = pay( $creditSum , $payout , 3 , 1000 , 0 ) ;
$strawberryBank = pay( $creditSum , $payout , 2 , 0 , 7777 ) ;
echo "homoCredit: {$homoCredit} руб.\n " ;
echo "softbank: {$softbank} руб.\n " ;
echo "strawberryBank: {$strawberryBank} руб.\n " ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBwYXkoJGNyZWRpdFN1bSwgJHBheW91dCwgJHBlcmNlbnQsICRzZXJ2aWNlUGF5LCAkb3BlbmluZykgewoJJGNyZWRpdFN1bSA9ICRjcmVkaXRTdW0gKyAkb3BlbmluZzsKCWZvciAoJGkgPSAwOyAkaSA8IDMwOyAkaSsrKSB7CgkJaWYgKCRjcmVkaXRTdW0gPD0gJHBheW91dCkgewoJCQkkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRjcmVkaXRTdW07CgkJCWJyZWFrOwoJCX0gZWxzZSB7CgkJCSRjcmVkaXRTdW0gPSAoJGNyZWRpdFN1bSAvIDEwMCAqICgxMDAgKyAkcGVyY2VudCkpICsgJHNlcnZpY2VQYXkgLSAkcGF5b3V0OwoJCSAgICAkcGF5bWVudFRvdGFsID0gJHBheW1lbnRUb3RhbCArICRwYXlvdXQ7CgkJfQoJfQoJcmV0dXJuICRwYXltZW50VG90YWw7Cn0KCiRjcmVkaXRTdW0gID0gNDAwMDA7CiRwYXlvdXQgPSA1MDAwOwoKJGhvbW9DcmVkaXQgPS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