Compound Interest Formula

Description: Calculates the value of an investment provided the initial principal, percentage rate, compoundings per year over a certain number of years.
Tested Platform: All Modern Browsers
Language: JavaScript
// Simple compound interest formula. 
// Provide initial principal, annual rate (as percentage), number of compoundings over years.
// Remember to round appropriately for money.

function compoundInterest(principal, annualRate, compoundings, years) {
	return principal * Math.pow(1 + ((annualRate / 100) / compoundings), compoundings * years);

Submitted: January 09, 2013

Return to the snippets listing