Skip to main content

Practice · 3 of 5

Count the calls

CHALLENGE
Difficulty: intermediate+25 XP

Implement int g(int n): the total number of calls f(n) makes (including itself), where f halves n each time. A loop counting halvings is fine — the point is the mental model: calls = frames on the stack at the deepest point.

Back to lesson: Practice: Recursion lab