Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how recursion works in python

def factorial(x):
    """This is a recursive function
    to find the factorial of an integer"""

    if x == 1:
        return 1
    else:
        return (x * factorial(x-1))


num = 1
print("The factorial of", num, "is", factorial(num))
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #recursion #works #python
ADD COMMENT
Topic
Name
5+7 =