Skip to content

Instantly share code, notes, and snippets.

@n8agrin
Created June 13, 2009 16:10
Show Gist options
  • Save n8agrin/129305 to your computer and use it in GitHub Desktop.
Save n8agrin/129305 to your computer and use it in GitHub Desktop.
function pmt(start, rate_as_percentage, num_periods, lifetime) {
var rate_per_period = ((rate_as_percentage/100) / num_periods);
// e.g. num_periods == 12 months, lifetimes = 4 years for 4 years, 12 months per year
var total_periods = num_periods * lifetime;
var p = (start * rate_per_period * Math.pow((1 + rate_per_period), total_periods)) / (Math.pow((1+rate_per_period), total_periods)-1);
console.log(Math.pow((1 + rate_per_period), total_periods));
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment