Last active
April 21, 2019 02:12
-
-
Save jiggzson/55386d7e1d593c679ed3511445874e70 to your computer and use it in GitHub Desktop.
A fast 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
var factorial = function(n) { | |
if(n === 0) | |
return 1; | |
var f = n; | |
while(n > 1) { | |
f *= --n; | |
} | |
return f; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment