<?php
$amountCredit = 40000;
$percent = 0.03;
$commission = 1000;
$payment = 5000;
$amountPayment = 0;
$finalPayment = 0;
for($month = 0; $amountCredit != 0; $month++){
$amountCredit += $percent*$amountCredit + $commission;
if ($amountCredit < $payment){
$amountPayment += $amountCredit;
$amountCredit -= $amountCredit;
}else{
$amountPayment += $payment;
$amountCredit -= $payment;
}
}
echo "Школьнику айфон обошелся в {$amountPayment} \n";
echo "Избавился от долга за {$month}";
?>
PD9waHAKICAgIGVycm9yX3JlcG9ydGluZygtMSk7CiAgICAKICAgICRhbW91bnRDcmVkaXQgPSA0MDAwMDsKCSRwZXJjZW50ID0gMC4wMzsKCSRjb21taXNzaW9uID0gMTAwMDsKCSRwYXltZW50ID0gNTAwMDsKCQoJJGFtb3VudFBheW1lbnQgPSAwOwoJJGZpbmFsUGF5bWVudCA9IDA7CgkKCWZvcigkbW9udGggPSAwOyAkYW1vdW50Q3JlZGl0ICE9IDA7ICRtb250aCsrKXsKCQkkYW1vdW50Q3JlZGl0ICs9ICRwZXJjZW50KiRhbW91bnRDcmVkaXQgKyAkY29tbWlzc2lvbjsKCQlpZiAoJGFtb3VudENyZWRpdCA8ICRwYXltZW50KXsKCQkJJGFtb3VudFBheW1lbnQgKz0gJGFtb3VudENyZWRpdDsKCQkJJGFtb3VudENyZWRpdCAtPSAkYW1vdW50Q3JlZGl0OwoJCX1lbHNlewoJCQkkYW1vdW50UGF5bWVudCArPSAkcGF5bWVudDsKCQkJJGFtb3VudENyZWRpdCAtPSAkcGF5bWVudDsKCQl9Cgl9CgllY2hvICLQqNC60L7Qu9GM0L3QuNC60YMg0LDQudGE0L7QvSDQvtCx0L7RiNC10LvRgdGPINCyIHskYW1vdW50UGF5bWVudH0gXG4iOwoJZWNobyAi0JjQt9Cx0LDQstC40LvRgdGPINC+0YIg0LTQvtC70LPQsCDQt9CwIHskbW9udGh9IjsKCQo/Pg==