Answers for "recursive funtion in python"

5

recursive function in python

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

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


num = 3
print("The factorial of", num, "is", factorial(num))
Posted by: Guest on January-17-2021
4

recursion in python

def rec(num):
    if num <= 1:
        return 1
    else:
        return num + rec(num - 1)

print(rec(50))
Posted by: Guest on March-03-2021

Python Answers by Framework

Browse Popular Code Answers by Language