Last active
March 28, 2019 22:07
-
-
Save HoraceShmorace/5b3ade7e5f90c79df0d7190500dc3cca to your computer and use it in GitHub Desktop.
Calculate simple earnings with compounded interest (margins)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MAX_PERIODS = 52 | |
const MARGIN_PER_PERIOD = 0.05 | |
function calc(v, t) { | |
console.log(v) | |
if (t === 0) return v; | |
const n = (v * MARGIN_PER_PERIOD) + v | |
return calc(n, --t) | |
} | |
calc(5000, MAX_PERIODS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment