HOME/Articles/

python code recursive functions (snippet)

Article Outline

Python example 'python code recursive functions'

python code recursive functions

Python code example: python code recursive functions

>>> def factorial_r(n):
if n == 0:
return 1
return n * factorial_r(n - 1)
>>>
>>> def factorial_l(n):
if n == 0:
return 1
product = 1
for i in range(1, n+1):
product *= i
return product

More Python: https://pythonprogramminglanguage.com