Skip to content
Truth Academy.
Truth Academy
← Computer Science

Core Disciplines · 14 min

Recursion: functions that call themselves

0 of 3

How many people are in front of you in a long line? Ask the person ahead. They ask the person ahead of them, and so on, until the front person says 'zero'. That's recursion.

Predict first

def countdown(n): if n == 0: print("Go!") else: print(n); countdown(n - 1). What does countdown(3) print?

def countdown(n): if n == 0: print("Go!") else: print(n); countdown(n - 1). What does countdown(3) print?

Concepts: Recursion · Programming basics