function update(){ var numYears = 'N/A'; var numPeriodsPerYear = 12; var interestRate = document.getElementById('interestRate').value; var depositAmount = document.getElementById('monthlyDeposit').value; var totalBalance = 1000000; var currentAge = document.getElementById('currentAge').value; var ageMillion = 0; // validate input if (!isValidNum(numYears)){ numYears = 0; } if (!isValidNum(numPeriodsPerYear)){ numPeriodsPerYear = 0; } if (!isValidNum(interestRate)){ interestRate = 0; }else if (interestRate != 0){ interestRate = (interestRate / 100); } if (!isValidNum(depositAmount)){ depositAmount = 0; } // check interest rate is specified so balance can grow if (interestRate != 0){ // n = (1/q) log(1 + [(iP)/(Mq)])/log(1 + [i/q]) var part1 = (1 / numPeriodsPerYear); var part2 = ((interestRate * totalBalance) / (depositAmount * numPeriodsPerYear)); var part3 = log10((1+part2)); var part4 = (interestRate / numPeriodsPerYear); var part5 = log10((1+part4)); numYears = formatTo((part1 * part3 / part5),0); ageMillion = formatTo((Number(numYears) + Number(currentAge)),0); } document.getElementById('time').value = numYears; document.getElementById('ageMillion').value = ageMillion; } function log10(x){ return Math.LOG10E * Math.log(x); }
33 shares 7 View comments 'The most powerful force in the universe is compound interest' - so said Albert Einstein. That's some claim but once you see how returns build on returns each year it's easy to see why he was so impressed. The official mid-point guidance for annual stock market returns is 6 per cent. Try adding that in and see at what age you might be able to save £1million.
Money saver tool: See how you can spend less to save more