# Program to compute 20! # Matt Bishop, Feb. 17, 2012 # for ECS 10 Winter 2012 # # compute n! # def fact(n): if n == 0: # base case return 1 else: # recursion return n * fact(n-1) def main(): # input number try: n = int(input("Factorial: ")) except: print("Need an integer") return # it better be non-negative! if n < 0: print("Need a non-negative integer") return # compute n! and announce it print("%d! =" % n, fact(n)) main()