Recursive definition of function factorial : Function Recursive « Function « Python






Recursive definition of function factorial

Recursive definition of function factorial

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 ) )


           
       








Related examples in the same category

1.Recursive fibonacci function.Recursive fibonacci function.
2.Function recursive DemoFunction recursive Demo