<?php
function getBalance($percent, $commission) {
$paymentTotal=0;
$creditSum=39999;
$payout=5000;
for($month=0;$month<=20;$month++){
$creditSum=$creditSum*$percent+$commission;
if($creditSum<$payout) {
$paymentTotal+=$creditSum;
$creditSum=0;
break;
}
else{
$creditSum-=$payout;
$paymentTotal+=$payout;
}
}
return $paymentTotal;
}
$homoCreditTotal=getBalance(1.04, 500);
$softBankTotal=getBalance(1.03, 1000);
$strawberryBankTotal=getBalance(1.02, 0) + 7777;
echo "homoCredit: {$homoCreditTotal} руб.\n";
echo "softBank: {$softBankTotal} руб.\n";
echo "strawberryBank: {$strawberryBankTotal} руб.\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgkKZnVuY3Rpb24gZ2V0QmFsYW5jZSgkcGVyY2VudCwgJGNvbW1pc3Npb24pIHsKCSRwYXltZW50VG90YWw9MDsKCSRjcmVkaXRTdW09Mzk5OTk7CgkkcGF5b3V0PTUwMDA7CgkKCWZvcigkbW9udGg9MDskbW9udGg8PTIwOyRtb250aCsrKXsKCQkJJGNyZWRpdFN1bT0kY3JlZGl0U3VtKiRwZXJjZW50KyRjb21taXNzaW9uOwoJCgkJaWYoJGNyZWRpdFN1bTwkcGF5b3V0KSB7CgkJCSRwYXltZW50VG90YWwrPSRjcmVkaXRTdW07CgkJCSRjcmVkaXRTdW09MDsKCQkJYnJlYWs7CgkJfQoJCWVsc2V7CgkJICRjcmVkaXRTdW0tPSRwYXlvdXQ7CgkJICAkcGF5bWVudFRvdGFsKz0kcGF5b3V0OwoJCX0JCgl9CglyZXR1cm4gJHBheW1lbnRUb3RhbDsKCX0KCSRob21vQ3JlZGl0VG90YWw9Z2V0QmFsYW5jZSgxLjA0LCA1MDApOwoJJHNvZnRCYW5rVG90YWw9Z2V0QmFsYW5jZSgxLjAzLCAxMDAwKTsKCSRzdHJhd2JlcnJ5QmFua1RvdGFsPWdldEJhbGFuY2UoMS4wMiwgMCkgKyA3Nzc3OwoJCgllY2hvICJob21vQ3JlZGl0OiB7JGhvbW9DcmVkaXRUb3RhbH0g0YDRg9CxLlxuIjsKCWVjaG8gInNvZnRCYW5rOiB7JHNvZnRCYW5rVG90YWx9INGA0YPQsS5cbiI7CgllY2hvICJzdHJhd2JlcnJ5QmFuazogeyRzdHJhd2JlcnJ5QmFua1RvdGFsfSDRgNGD0LEuXG4iOw==