<?php
function chooseBank($percent, $comission, $openPayment) {
$creditSum = 39999;
$payout = 5000;
$totalPayment = 0 + $openPayment;
for ($i = 1; $creditSum > 0; $i++) {
$monthlyPayment = $creditSum * $percent + $comission;
$creditSum = $creditSum + $monthlyPayment;
if ($creditSum < 5000) {
$payout = $creditSum;
$creditSum = $creditSum - $payout;
$totalPayment = $totalPayment + $payout;
break;
}
$creditSum = $creditSum - $payout;
$totalPayment = $totalPayment + $payout;
}
return $totalPayment;
}
$homoCreditTotal = chooseBank(0.04, 500, 0);
$softbankTotal = chooseBank(0.03, 1000, 0);
$strawberryBankTotal = chooseBank(0.02, 0, 7777);
echo "homoCredit: {$homoCreditTotal} руб.\n";
echo "softbank: {$softbankTotal} руб.\n";
echo "strawberryBank: {$strawberryBankTotal} руб.\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBjaG9vc2VCYW5rKCRwZXJjZW50LCAkY29taXNzaW9uLCAkb3BlblBheW1lbnQpIHsKCQoJJGNyZWRpdFN1bSA9IDM5OTk5OwogICAgJHBheW91dCA9IDUwMDA7CgkkdG90YWxQYXltZW50ID0gMCArICRvcGVuUGF5bWVudDsKCWZvciAoJGkgPSAxOyAkY3JlZGl0U3VtID4gMDsgJGkrKykgewoJCSRtb250aGx5UGF5bWVudCA9ICAkY3JlZGl0U3VtICogJHBlcmNlbnQgKyAkY29taXNzaW9uOwoJICAgICRjcmVkaXRTdW0gPSAkY3JlZGl0U3VtICsgJG1vbnRobHlQYXltZW50OwoJICAgIGlmICgkY3JlZGl0U3VtIDwgNTAwMCkgewoJICAgIAkkcGF5b3V0ID0gJGNyZWRpdFN1bTsKCSAgICAJJGNyZWRpdFN1bSA9ICRjcmVkaXRTdW0gLSAkcGF5b3V0OwoJICAgIAkkdG90YWxQYXltZW50ID0gJHRvdGFsUGF5bWVudCArICRwYXlvdXQ7CgkgICAgCWJyZWFrOwoJICAgIH0KCSAgICAkY3JlZGl0U3VtID0gJGNyZWRpdF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