Programming (en)

Factorial recursive function in Python ?


QUID ? >>>
def factorial (x):
    if x == 1: # base condition
        return 1
    else:
        y = factorial (x-1)
        print (y,"*",x,"=",x * y)
        return (x * y)

# testing factorial function for a given number
number = 50
print ("Computing", number, "!")
factorial (number)

# program: Factorial recursive function
# implementation in Python 3.x: A.-P. Gaspar
image_print

Leave a Reply

Your email address will not be published. Required fields are marked *

,

English - Programming (en)