Recursive factorial function. : recursive function « Function « Python Tutorial






def factorial( number ):

   if number <= 1:   # base case
      return 1
   else:
      return number * factorial( number - 1 )  # recursive call

for i in range( 11 ):
   print "%2d! = %d" % ( i, factorial( i ) )








10.13.recursive function
10.13.1.Recursion
10.13.2.Recursive factorial function.
10.13.3.Recursive fibonacci function.
10.13.4.Recursive Functions