# memory.py # Walker M. White (wmw2) # October 15, 2013 """A module to show off the dangers of recursion. What happens when you forget a base case. Try this module out and see.""" import sys # Allow us to go really deep sys.setrecursionlimit(999999999) def factorial(n): """Returns: n! Parameter n: the number to compute Precondition: n is a nonnegative integer""" #assert type(n) == int, `n`+' is not an int' # get in the habit #assert n >= 0, `n`+' is negative' # get in the habit #if n==0: # Base case # return 1 # Recursive case. return n*factorial(n-1)