Algorithms

Base case

The problem so small that a recursive function solves it without calling itself again. It's what makes recursion end.

Example

In the sum f(n) = n + f(n − 1), the base case is f(1) = 1. Without it, f(3) would go on to f(0), f(−1)... forever.

Test yourself: Base case

Iteration and recursion

What is the base case for in a recursive function?

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.