Javascript 如何使用Math.pow()解复利?

Javascript 如何使用Math.pow()解复利?,javascript,math,exponent,Javascript,Math,Exponent,我试图用javascript计算复利。我相信我有我需要的所有价值观,我也有公式。我正在努力将公式的^部分翻译成Math.pow()。这将是痛苦的明显,我不知道如何正确使用它下面 以下是公式: A = P(1 + r/n)^nt n = 365 – assuming daily compounding P = Principal r = interest rate t = years A = accrued amount: principal + interest 以下是我到目前为止的情况:

我试图用javascript计算复利。我相信我有我需要的所有价值观,我也有公式。我正在努力将公式的
^
部分翻译成
Math.pow()
。这将是痛苦的明显,我不知道如何正确使用它下面

以下是公式:

A = P(1 + r/n)^nt

n = 365 – assuming daily compounding
P = Principal
r = interest rate
t = years
A = accrued amount: principal + interest
以下是我到目前为止的情况:

totalInterest = (principal) * (1 + loanInterestRate / 365)(Math.pow(daysOfInterest, yearsOfInterest));
例如,我将prime设置为
3.25%
,付款到期日设置为
12/30/2016
。使用值时,它看起来如下所示:

(50000) * (1 + 0.0325 / 386) Math.pow(386, 1);

// 386 is the number of days from today till 12/30/2016. 
// 1 is: 1 year from today till 12/30/2016
显然,这行不通。我不知道如何正确地实现数学,任何建议都会有帮助

谢谢大家!

编辑

再次感谢您的回答。这正是我所需要的动力——显然我不会数学

我想用我的完整答案更新这个

totalInterest = Math.round(((principal) * Math.pow(1 + loanInterestRate / 365, daysOfInterest * 1)) - principal);
loanNetCost = (principal) + (loanTotalInterest);

alert('You will owe this much money: + loanNetCost');

您需要将其更改为:

(50000) * Math.pow(1 + 0.0325 / 386, 386 * 1)

您需要将其更改为:

(50000) * Math.pow(1 + 0.0325 / 386, 386 * 1)

A = P * Math.pow(1 + r/n, nt);

A = P * Math.pow(1 + r/n, nt);
意思是
n^t
so
Math.pow(386,1)
意思是386乘以1的幂

您需要将所有表达式
(1+r/n)
提升到nt的幂

给予

(50000) * Math.pow(1 + 0.0325 / 386, 386 * 1)
意思是
n^t
so
Math.pow(386,1)
意思是386乘以1的幂

您需要将所有表达式
(1+r/n)
提升到nt的幂

给予

(50000) * Math.pow(1 + 0.0325 / 386, 386 * 1)

Math.pow()
的第一个参数是公式中
^
左边的数字,第二个参数是右边的数字。请注意,JS不懂代数
(foo)(bar)
是一种语法错误,或者至少是一种尝试调用函数的错误方式。必须是
(foo)*(bar)
。非常感谢大家!我非常感谢你的帮助!我检查答案只是因为它显示了公式。如果有人遇到此线程,他们可以看到优秀的示例。
Math.pow()
的第一个参数是公式中
^
左侧的数字,第二个参数是右侧的数字。请注意,JS不懂代数
(foo)(bar)
是一种语法错误,或者至少是一种尝试调用函数的错误方式。必须是
(foo)*(bar)
。非常感谢大家!我非常感谢你的帮助!我检查答案只是因为它显示了公式。如果有人遇到这个问题,他们可以看到很好的例子。