45.6k views
2 votes
If you create and invoke a recursive function without accounting for a base case, what can go wrong?

User Fwalch
by
7.8k points

1 Answer

2 votes

Every recursive function should have an exit criterion (=handling the base case) to exit the recursion.

Without it, it wil recurse forever, until system resources run out (typically the call stack will overflow and your program will crash).

User Piotr Kula
by
9.0k points

No related questions found