<?php
function checkTotal($percent,$comission){
$totalPrice=39999;
$payed=0;
$payment=5000;
for ($i=0; $totalPrice>$payed; $i++){
$totalPrice=$totalPrice*(1+$percent/100)+$comission;
$payed+=$payment;
}
return $totalPrice;
}
$homoPrice=checkTotal(4,500);
$softPrice=checkTotal(3,1000);
$strawberryPrice=checkTotal(2,0)+7777;
if (($homoPrice<$softPrice) && ($homoPrice<$strawberryPrice)){
$winBank="HomoCredit";
$winPrice=$homoPrice;
}elseif (($softPrice<$homoPrice) && ($softPrice<$strawberryPrice)){
$winBank="Softbank";
$winPrice=$softPrice;
}else{
$winBank="StrawberryBank";
$winPrice=$strawberryPrice;
}
echo ("Наиболее выгодным, очевидно, являяется предложение банка {$winBank}.\n");
echo ("По кредиту будет выплачено {$winPrice} руб., за ".ceil($winPrice/5000)." месяцев.");
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CmZ1bmN0aW9uIGNoZWNrVG90YWwoJHBlcmNlbnQsJGNvbWlzc2lvbil7CiAgICAkdG90YWxQcmljZT0zOTk5OTsKICAgICRwYXllZD0wOwogICAgJHBheW1lbnQ9NTAwMDsKICAgIGZvciAoJGk9MDsgJHRvdGFsUHJpY2U+JHBheWVkOyAkaSsrKXsKICAgICAgICAkdG90YWxQcmljZT0kdG90YWxQcmljZSooMSskcGVyY2VudC8xMDApKyRjb21pc3Npb247CgkkcGF5ZWQrPSRwYXltZW50OwogICAgfQogICAgcmV0dXJuICR0b3RhbFByaWNlOwp9CiRob21vUHJpY2U9Y2hlY2tUb3RhbCg0LDUwMCk7CiRzb2Z0UHJpY2U9Y2hlY2tUb3RhbCgzLDEwMDApOwokc3RyYXdiZXJyeVByaWNlPWNoZWNrVG90YWwoMiwwKSs3Nzc3OwoKaWYgKCgkaG9tb1ByaWNlPCRzb2Z0UHJpY2UpICYmICgkaG9tb1ByaWNlPCRzdHJhd2JlcnJ5UHJpY2UpKXsKICAgICR3aW5CYW5rPSJIb21vQ3JlZGl0IjsKICAgICR3aW5Qcm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