recursion python node code example
Example 1: recursion in python
def rec(num):
if num <= 1:
return 1
else:
return num + rec(num - 1)
print(rec(50))
Example 2: recursion python examples
# Recursive function factorial_recursion()
def factorial_recursion(n):
if n == 1:
return n
else:
return n*factorial_recursion(n-1)