javascript - 如何使用 Math.pow() 来求解复利?

标签 javascript math exponent

我正在尝试用 javascript 计算复利。我相信我拥有我需要的所有值(value)观,而且我也有公式。我正在努力解决如何将公式的 ^ 部分转换为 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));

作为示例,我将质数设置为 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)

关于javascript - 如何使用 Math.pow() 来求解复利?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34207470/

相关文章:

javascript - 在脚本源 Google Map API 中添加变量

java - 对于大数使用对数而不是除法?

Python:判断数字是否为正方形、立方体等的函数

math - OpenGL 矩阵 VS DirectX 矩阵

asp.net - 防止数字以指数表示法显示的更简单方法

javascript - 在 jQuery UI 中调用调整大小事件

javascript - NodeJS Promise,延迟返回值

javascript - 如何让 jquery jScrollPane 和 jscrollHorizo​​ntalPane 插件一起工作?

c++ - float 的指数偏差有规范吗?

swift - 如何将二进制指数为-10的数字转换为 float ?