From 7c3925caf2a627d38c84a2a528717c9c5b74883f Mon Sep 17 00:00:00 2001 From: skeepwalk Date: Sun, 25 Dec 2022 17:29:21 +0500 Subject: [PATCH] aaaaaa --- "\320\270\320\277\320\276\321\202\320\265\320\272.php" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "\320\270\320\277\320\276\321\202\320\265\320\272.php" 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); +