Created
April 28, 2016 15:35
-
-
Save ChrisWhealy/d63d9d7922d3bba084e3527b3e99b210 to your computer and use it in GitHub Desktop.
Imperative implementation of the factorial function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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