- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- Время выплаты: 13 месяцев, сумма выплаты: 61271
<?php
$initialCredit = 40000;
$monthlyPayment = 5000;
$creditInterestPercent = 3;
$commission = 1000;
$remainingCredit = $initialCredit;
$paid = 0;
$monthCount = 0;
$creditInterest = $remainingCredit / 100 * $creditInterestPercent;
$creditIncrease = $creditInterest + $commission;
if ($creditIncrease >= $monthlyPayment) {
echo 'Кредит выплатить невозможно. Обслуживание выше ежемесячной платы.';
return;
}
while ($remainingCredit > 0) {
$creditInterest = $remainingCredit / 100 * $creditInterestPercent;
$creditIncrease = $creditInterest + $commission;
$remainingCredit += $creditIncrease;
$payment = min($remainingCredit, $monthlyPayment);
$remainingCredit -= $payment;
$paid += $payment;
$monthCount++;
}
echo 'Время выплаты: ' . $monthCount . ' месяцев, сумма выплаты: ' . ceil($paid);