Skip to content

Instantly share code, notes, and snippets.

@TejasQ
Created January 28, 2023 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TejasQ/f40fc0ca03b2be5a8b39946d3a255e71 to your computer and use it in GitHub Desktop.
Save TejasQ/f40fc0ca03b2be5a8b39946d3a255e71 to your computer and use it in GitHub Desktop.
etf calculator
let appreciation=.0238;
let initial=80000;
let lastMultiplier = 1;
for (i=0; i<50; i++) {
const a = initial;
const currentMultiplier = Math.floor(initial/80000);
initial = Math.round(initial + (initial * appreciation));
if (lastMultiplier < currentMultiplier) {
lastMultiplier = currentMultiplier;
console.log(`${i} years until ${currentMultiplier}x.`);
}
//console.log(`Year ${i+1}: Start at ${a}, end at ${initial}. Gain is ${Math.round(initial-a)}. Difference to beginning = ${initial/80000}x.`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment