<?php
function getFinalPrice ($credit, $pay, $loanRate, $comission){
$totalPay = 0;
while ($credit > 0):
$credit = $credit * (1 + $loanRate/100) + $comission - $pay;
$totalPay += $pay;
endwhile;
$totalPay += $credit;
return $totalPay;
}
$homoCreditTotal = getFinalPrice(39999, 5000, 4, 500);
$softBankTotal = getFinalPrice(39999, 5000, 3, 1000);
$strawberryBankTotal = getFinalPrice(47776, 5000, 2, 0);
echo "HomoCredit: $homoCreditTotal руб.\n";
echo "SoftBank: $softBankTotal руб.\n";
echo "StrawberryBank: $strawberryBankTotal руб.\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBnZXRGaW5hbFByaWNlICgkY3JlZGl0LCAkcGF5LCAkbG9hblJhdGUsICRjb21pc3Npb24pewoJJHRvdGFsUGF5ID0gMDsKCXdoaWxlICgkY3JlZGl0ID4gMCk6CgkkY3JlZGl0ID0gJGNyZWRpdCAqICgxICsgJGxvYW5SYXRlLzEwMCkgKyAkY29taXNzaW9uIC0gJHBheTsKCSR0b3RhbFBheSArPSAkcGF5OwoJZW5kd2hpbGU7CgkkdG90YWxQYXkgKz0gJGNyZWRpdDsKCXJldHVybiAkdG90YWxQYXk7Cn0KCgokaG9tb0NyZWRpdFRvdGFsID0gZ2V0RmluYWxQcmljZSgzOTk5OSwgNTAwMCwgNCwgNTAwKTsKJHNvZnRCYW5rVG90YWwgPSBnZXRGaW5hbFByaWNlKDM5OTk5LCA1MDAwLCAzLCAxMDAwKTsKJHN0cmF3YmVycnlCYW5rVG90YWwgPSBnZXRGaW5hbFByaWNlKDQ3Nzc2LCA1MDAwLCAyLCAwKTsKCgplY2hvICJIb21vQ3JlZGl0OiAkaG9tb0NyZWRpdFRvdGFsINGA0YPQsS5cbiI7CmVjaG8gIlNvZnRCYW5rOiAkc29mdEJhbmtUb3RhbCDRgNGD0LEuXG4iOwplY2hvICJTdHJhd2JlcnJ5QmFuazogJHN0cmF3YmVycnlCYW5rVG90YWwg0YDRg9CxLlxuIjs=