Learn practical skills, build real-world projects, and advance your career
Updated 3 years ago
This notebook is to learn and understand some of the concepts for recursion through examples.
Factorial using recursion
There must be one base case and one recursive case
def factorial(n):
if n == 1: # Base case = at what point do you stop in a recursion
return n
else: # Recursive case
return n*factorial(n-1)
factorial(4)
24
from IPython.display import Image
Image(filename='Screen Shot 2020-10-20 at 09.05.17.png', width=800)