Created
July 21, 2011 20:46
-
-
Save mattyw/1098163 to your computer and use it in GitHub Desktop.
When you're bored, do some recursion
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
def fact(x): | |
if x == 0: | |
return 0 | |
elif x == 1: | |
return 1 | |
else: | |
return x * fact(x-1) | |
for x in range(0,10): | |
print x, fact(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment