python how to do recursion 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 in python
def yourFunction(arg):
#you can't just recurse over and over,
#you have to have an ending condition
if arg == 0:
yourFunction(arg - 1)
return arg