Python Recursion
Python Recursion
We can let the function call itself, such a process is known as calling a function recursively in python.
Example:
Output:
We can let the function call itself, such a process is known as calling a function recursively in python.
Example:
def factorial(num):
if (num == 1 or num == 0):
return 1
else:
return (num * factorial(num - 1))
# Driver Code
num = 7;
print("number: ",num)
print("Factorial: ",factorial(num))
Output:
number: 7
Factorial: 5040
Sorry, we detected that you have activated Ad-Blocker.
Please consider supporting us by disabling your Ad-Blocker, it helps us in developing this Website.
Thank you!