Skip to content

Instantly share code, notes, and snippets.

@ChrisWhealy
Created April 28, 2016 15:35
Show Gist options
  • Save ChrisWhealy/d63d9d7922d3bba084e3527b3e99b210 to your computer and use it in GitHub Desktop.
Save ChrisWhealy/d63d9d7922d3bba084e3527b3e99b210 to your computer and use it in GitHub Desktop.
Imperative implementation of the factorial function
function factorial(n) {
var result = 1;
while (n>1) {
result = result * n;
n = n - 1;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment