問題:
當基礎利率也以每年恒定的增長率(例如 10%)增加時,我如何計算復利?
示例:
1000 美元,年利率 5%,為期 5 年。
這是我計算復利的方式:
復利
let principal = 1000;
let n = 1;
let t = 5;
let rate = 10;
let r = rate/100;
let compoundInterest = principal*Math.pow((1 r/n),nt);
但現在我實際上希望利率本身在第一年過去后每年增加 10%。
第一年:5%
第二年:5% (5 * 0,1) = 5,5%
第三年:5,5% (5,5 * 0,1) = 6,05%
uj5u.com熱心網友回復:
給定起始條件:
let startingPrincipal = 1000;
let numberOfYears = 5;
let startingRate = 10;
let rateIncreaseRate = 10;
您可以計算每一年的年利率,將更新后的余額和新利率提供給它。我簡化了公式,因為您有年度復利,并且每個時期的計算僅為 1。如果您想在一年內以不同的方式復利,請告訴我。
let yearlyInterest = startingRate;
let currentBalance = startingPrincipal;
for (let i = 0; i < numberOfYears; i ) {
currentBalance *= 1 yearlyInterest / 100;
yearlyInterest *= 1 rateIncreaseRate / 100;
}
console.log(currentBalance);
輸出:
1777.9906868317107
您可以根據您的要求對其進行舍入或截斷。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/368449.html
標籤:javascript 数学
