<?php

error_reporting(-1);

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";