Fix compound interest formula

https://en.wikipedia.org/wiki/Compound_interest
This commit is contained in:
Andrei Shevchuk 2021-08-14 05:09:29 +03:00
parent bc08fd1b32
commit f17c07af83
2 changed files with 2 additions and 2 deletions

View file

@ -96,7 +96,7 @@
let years = form.months.value / 12;
if (!years) return;
let result = Math.round(initial * (1 + interest * years));
let result = Math.round(initial * (1 + interest) ** years);
let height = result / form.money.value * 100 + 'px';
document.getElementById('height-after').style.height = height;

View file

@ -17,5 +17,5 @@ The formula is:
// initial: the initial money sum
// interest: e.g. 0.05 means 5% per year
// years: how many years to wait
let result = Math.round(initial * (1 + interest * years));
let result = Math.round(initial * (1 + interest) ** years);
```