<?php
 
error_reporting(-1);
 
$credit = 40000;
$percent = 1.03;
$comission = 1000;
$truePrice = 0;
$pay = 5000;
 
$credit = $credit * $percent;
 
 
for ($mouth = 1;$credit > 0;$mouth++) {
    $credit = ($credit * $percent) + $comission;
	if ($credit < 5000) {
		$truePrice = $credit + $truePrice;
		break;
	}
 
	$credit = $credit - $pay;
	$truePrice = $truePrice + $pay;
}
 
echo "Школяр отдавал кредит $mouth месяцев и вожделенный айфон обошёлся ему в $truePrice рублей!";
 
?>