Mathematics I / Recursion
Practice question · Fill in the blanks

Complete the condition for a recursion to terminate.

A recursive function fails to terminate when its calls ______.

Word bank: reach the base case too quickly · do not make the problem strictly smaller · return a value each time · use a loop instead of recursion

Hints
  1. A base case is necessary but not sufficient.
  2. A call on the SAME size of problem makes no progress at all.
Show the answer

A recursive function fails to terminate when its calls do not make the problem strictly smaller.

Why

Progress is the second requirement: each call must shrink the problem so the base case is eventually reached. A definition like f(n) = f(n) + 1 has a base case that is simply never reached.

Read the lesson: Recursion →

Practise Recursion

The app has 6 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Recursion