Created
September 18, 2013 19:19
-
-
Save smithcommajoseph/6614158 to your computer and use it in GitHub Desktop.
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
if (typeof Math.factorial === "undefined") { | |
Math.factorial = function factorial (n) { | |
if (n == 0 || n == 1) | |
return 1; | |
if (Math.factorial.f[n] > 0) | |
return Math.factorial.f[n]; | |
else | |
return Math.factorial.f[n] = factorial(n-1) * n; | |
}; | |
Math.factorial.f = []; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment