Skip to content

Instantly share code, notes, and snippets.

@ghalimi
Created January 23, 2013 22:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghalimi/4614489 to your computer and use it in GitHub Desktop.
Save ghalimi/4614489 to your computer and use it in GitHub Desktop.
NOMINAL
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function NOMINAL(rate, periods) {
// Return error if any of the parameters is not a number
if (isNaN(rate) || isNaN(periods)) return '#VALUE!';
// Return error if rate <=0 or periods < 1
if (rate <=0 || periods < 1) return '#NUM!';
// Truncate periods if it is not an integer
periods = parseInt(periods, 10);
// Return nominal annual interest rate
return (Math.pow(rate + 1, 1 / periods) - 1) * periods;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment