Open the editor

Computer science · High school

Recursion Slides

Free animated slides, ready to teach: 6 slides where every step appears on a click and the diagrams move. Play them right here, present them full screen, or copy them into your account to edit.

A real Tracé deck playing in your browser. No account needed.

What the lesson covers

A recursive function solves a problem by calling itself on a smaller version of it, until a base case stops it. Students read a factorial function, watch the calls stack up and return, and trace a recursive power calculation.

The slides, one by one

1 Recursion

A function that calls itself

How can a function use itself to solve a problem?

2 Call yourself on a smaller problem

n! = n \times (n - 1)!

The base case stops the calls

3 Calls stack up, then unwind

Each call waits for the one below

Answers return back up: 1, 2, 6

4 A recursive power

power(b, n) returns 1 if n = 0, otherwise b × power(b, n − 1). Trace power(2, 5).

→ Unwind the calls down to the base case, then multiply back up

2^5 = 2 \times 2^4
2^4 = 2 \times 2^3
\dots\ 2^0 = 1\ (\text{base case})
2^5 = 2 \times 2 \times 2 \times 2 \times 2 \times 1 = 32

power(2, 5) = 32, after 6 calls

5 Quick check

What goes wrong if a recursive function has no base case?

  • It never stops: stack overflow
  • It returns 0
  • It runs only once
  • It runs faster
Show the answer

It never stops: stack overflow

Without a base case each call makes another, until the call stack runs out of memory.

6 What to remember

A function that calls itself

Base case: answered directly

Each call moves towards the base case

The call stack winds up, then unwinds

Challenge: Write sum(n) = 1 + 2 + … + n as a recursive function.

Every slide is built click by click: text, formulas and pictures come in one step at a time, so the class follows the reasoning instead of reading ahead. Graphs with sliders can be dragged live while you present.

Make your own version with AIChange the level, the numbers or the language: type the topic and get a new deck that moves in about 30 seconds. Free, no account needed.

Questions teachers ask

What is a base case in recursion?

The simplest input, which the function answers directly without calling itself, such as factorial(1) = 1. Every recursive call must move closer to the base case, or the calls never stop and the stack overflows.

Are these slides really free?

Yes. Watch them on this page or present them full screen with no account. Making your own copy to edit is free too.

Can I change the slides before my lesson?

Yes. Press "Make my own copy" and the deck becomes one of your projects in the Tracé editor, where you can change the text, the numbers, the colours or the order of the clicks.

Do they work on a classroom projector or an interactive whiteboard?

Yes. They run in the browser on any laptop, so anything that shows your screen works. Press the right arrow or click to go to the next step.