Lesson 9 of 24
Recursion
10 min 30 XP
In recursion a function calls itself on a smaller input until a base case stops it. The Tower of Hanoi is the classic example: n disks need 2ⁿ - 1 moves.
Example: edit me and press Run
Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.