Learn the fundamental concepts of computer programming
Recursion occurs when a function calls itself from within its own code.
It is a powerful tool for breaking down complex problems into simpler ones, like traversing a file system tree or calculating factorials.
Every recursive function MUST have a base case—a condition that stops the recursion. Without a base case, the function will call itself infinitely, causing an "infinite loop" or "stack overflow".
Edit the code below and click Run to see the result live.