diff --git "a/\320\270\320\277\320\276\321\202\320\265\320\272.php" "b/\320\270\320\277\320\276\321\202\320\265\320\272.php" new file mode 100644 index 0000000..e137608 --- /dev/null +++ "b/\320\270\320\277\320\276\321\202\320\265\320\272.php" @@ -0,0 +1,8 @@ +function mortgagePayment($principal, $interestRate, $termMonths, $monthsPaid) { + // рассчитываем месячную процентную ставку + $monthlyInterestRate = $interestRate / 12; + // рассчитываем аннуитетный платеж + $payment = $principal * $monthlyInterestRate / (1 - pow(1 + $monthlyInterestRate, -$termMonths)); + // рассчитываем остаток задолженности после $monthsPaid месяцев + $remainingBalance = $principal * pow(1 + $monthlyInterestRate, $monthsPaid) - $payment * ((pow(1 + $monthlyInterestRate, $monthsPaid) - 1) / $monthlyInterestRate); +