To understand recursion, you must first understand recursion.
Recursion is when a function calls itself. It's like a Russian nesting doll — each doll contains a smaller version of itself, and you keep opening them until you reach the smallest one.
# 5! = 5 × 4 × 3 × 2 × 1
# 5! = 5 × 4!
def factorial(n):
if n == 1: # Base case
return 1
return n * factorial(n - 1) # Recursive case