using recursion in python api code example
Example 1: python recursion example
# Recursive Factorial Example
# input: 5
# output: 120 (5*4*3*2*1)
def factorial(x):
if x == 1:
return 1
else:
return (x * factorial(x-1))
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