Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming / Recursion / The base case

Quiz — The base case

What happens if a recursive subroutine has no reachable base case?

0It returns Nil
0It returns 0
1It never stops calling itself and eventually fails
0The compiler refuses to run it

With no reachable base case, each call makes another call without end. The recursion never terminates, and the program eventually runs out of call stack and fails. A base case is what lets the recursion stop.

Course navigation

The base case   |   Power