Fix compound interest formula
https://en.wikipedia.org/wiki/Compound_interest
This commit is contained in:
parent
bc08fd1b32
commit
f17c07af83
2 changed files with 2 additions and 2 deletions
|
@ -96,7 +96,7 @@
|
||||||
let years = form.months.value / 12;
|
let years = form.months.value / 12;
|
||||||
if (!years) return;
|
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';
|
let height = result / form.money.value * 100 + 'px';
|
||||||
document.getElementById('height-after').style.height = height;
|
document.getElementById('height-after').style.height = height;
|
||||||
|
|
|
@ -17,5 +17,5 @@ The formula is:
|
||||||
// initial: the initial money sum
|
// initial: the initial money sum
|
||||||
// interest: e.g. 0.05 means 5% per year
|
// interest: e.g. 0.05 means 5% per year
|
||||||
// years: how many years to wait
|
// years: how many years to wait
|
||||||
let result = Math.round(initial * (1 + interest * years));
|
let result = Math.round(initial * (1 + interest) ** years);
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue