2015-09-05 52 views
-1

所以我不是最好的數學或編程,我想弄清楚如何寫在JavaScript中。任何幫助都會非常感謝。你會如何在Javascript中寫這個?

M = P[i(1+i)^n]/[(1+i)^n -1] 

M = Monthly Payments 
P = Principle Amount 
I = Interest Rate 
N = Number of payments 

未來的感謝!

+2

大量通過簡單的Google搜索找到的代碼示例:https://www.google.com/search?q=monthly+payment+calculation+in+javascript。你也應該顯示你的嘗試和你研究的內容。 – jfriend00

回答

2

這是你在找什麼?

var P = 5; 
var i = 10; 
var n = 15; 
var M = (P*Math.pow(i*(1 + i), n))/(Math.pow(1 + i, n) - 1); 
console.log(M) 
2

這應該是它:

P*(i*Math.pow(1+i, n))/(Math.pow(1+i, n)-1) 

Math.pow(X,Y)給你X的y次冪,你必須使用簡單的括號 「()」 和multyplying總是用「 *」。

相關問題