Created
May 16, 2014 17:12
-
-
Save bitoffdev/982bfbff2a4127be3d9c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
memo = {1:1} | |
def fact(n): | |
global memo | |
if not n in memo: | |
if n > max(memo) + 500: | |
fact(min(n, max(memo)+500)) | |
memo[n] = n * fact(n-1) | |
return memo[n] | |
if __name__ == "__main__": | |
print "Test 10!:", fact(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment