<?php
function countMoney($creditSum, $initialFee, $percent, $comission, $payment, $payout)
{
$creditSum = $creditSum + $initialFee;
$percent = $percent + 100;
for ($i = 1; $i <= 20; $i++) {
$creditSum = $creditSum * $percent / 100 + $comission - $payout;
$payment = $i * $payout;
if ($creditSum * $percent / 100 + $comission < 5000) {
$payment = $payment + ($creditSum * $percent / 100 + $comission);
break;
}
}
return $payment;
}
//variables
$creditSum = 39999;
$payout = 5000;
$payment = 0;
$homocredit = countMoney($creditSum, 0, 4, 500, $payment, $payout);
echo "HomoCredit: {$homocredit} рублей.\n";
$softbank = countMoney($creditSum, 0, 3, 1000, $payment, $payout);
echo "SoftBank: {$softbank} рублей.\n";
$stawberrybank = countMoney($creditSum, 7777, 2, 0, $payment, $payout);
echo "StrawberryBank: {$stawberrybank} рублей.\n";
$benefit = min($homocredit, $softbank, $stawberrybank); echo "Наивыгодный кредит - {$benefit}!";
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKZnVuY3Rpb24gY291bnRNb25leSgkY3JlZGl0U3VtLCAkaW5pdGlhbEZlZSwgJHBlcmNlbnQsICRjb21pc3Npb24sICRwYXltZW50LCAkcGF5b3V0KQp7CiAgICAkY3JlZGl0U3VtID0gJGNyZWRpdFN1bSArICRpbml0aWFsRmVlOwogICAgJHBlcmNlbnQgICA9ICRwZXJjZW50ICsgMTAwOwogICAgZm9yICgkaSA9IDE7ICRpIDw9IDIwOyAkaSsrKSB7CiAgICAgICAgJGNyZWRpdFN1bSA9ICRjcmVkaXRTdW0gKiAkcGVyY2VudCAvIDEwMCArICRjb21pc3Npb24gLSAkcGF5b3V0OwogICAgICAgICRwYXltZW50ID0gJGkgKiAkcGF5b3V0OwogICAgICAgIGlmICgkY3JlZGl0U3VtICogJHBlcmNlbnQgLyAxMDAgKyAkY29taXNzaW9uIDwgNTAwMCkgewogICAgICAgICAgICAkcGF5bWVudCA9ICRwYXltZW50ICsgKCRjcmVkaXRTdW0gKiAkcGVyY2VudCAvIDEwMCArICRjb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