<?php

error_reporting(-1);


function fcredit($credit, $percent, $comission) {
	for ($pay = 0; $credit >= 5000;) {
		$credit = $credit * $percent + $comission;
		$pay += 5000;
		$credit -= 5000;
		if ($credit < 5000) {
			$pay += $credit;
			$credit -= $credit;
		}
	}
	return $pay;
}

$credit = 39999;
$firstbank = fcredit($credit, 1.04, 500);
$secondbank = fcredit($credit, 1.03, 1000);
$thirdbank = fcredit($credit + 7777, 1.02, 0);

echo "homocredit: {$firstbank} rub\n";
echo "softbank: {$secondbank} rub\n";
echo "strawberrybank: {$thirdbank} rub\n";