2021年4月28日星期三

Compounding interest calculator with monthly contributions

I'm really struggling with what seems should be a fairly simple calculation...

I would like to calculate the compounding interest of an initial investment, with monthly contributions...

This is what I have so far:

function makeInvestingCalculation() {    let princ = 3500; // start deposit    let add = 250; // monthly deposit (need plus it every year)    let rate = 12 / 100; // interest rate divided to create decimal    let months = (10 * 12); //10 years of monthly contributions    for (let i = 0; i < months; i++) {      if (i != 0) {        princ += add;      }      princ += princ * rate;    }    console.log(princ.toFixed(2)); //4498379090.49  }    makeInvestingCalculation();

This produces 4498379090.49 which is clearly incorrect.

The correct answer is supposed to be 69,636.12 but I am unable to find this...

Any help would be greatly appreciated.

https://stackoverflow.com/questions/67310078/compounding-interest-calculator-with-monthly-contributions April 29, 2021 at 10:00AM

没有评论:

发表评论