Python - Recurrsion
Python - Recurrsion
Recursion in python
Recursion is the process of defining something in terms of itself.
Example:
def factorial(num):
return 1
else:
# Driver Code
num = 7;
print("Number: ",num)
print("Factorial: ",factorial(num))
Output:
number: 7
Factorial: 5040
Input:
def fibonacci(n):
if(n == 0):
return 0
elif(n == 1):
return 1
else:
https://notebook.zoho.in/app/index.html#/notebooks/dcr5z062df283b6d34515b57bede07611926f/notecards/9wn9od334643e2116417f9a2b8d6852ecc235 1/2
21/10/2024, 13:12 Python
Ouput :
Enter terms : 8
0
1
1
2
3
5
8
13
https://notebook.zoho.in/app/index.html#/notebooks/dcr5z062df283b6d34515b57bede07611926f/notecards/9wn9od334643e2116417f9a2b8d6852ecc235 2/2