"""
Recursive implementation of factorial
This function should be copied into the Python Tutor. That way you can
see how recursion affects the call stack.
Author: Walker M. White (wmw2)
Date: October 10, 2017 (Python 3 Version)
"""
def factorial(n):
"""
Returns: n!
Parameter n: the number to compute
Precondition: n is a nonnegative integer
"""
if n==0: # Base case
return 1
# Recursive case.
return n*factorial(n-1)
factorial(0)
factorial(1)
factorial(4)