Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A process where a function calls itself directly or indirectly. It's a powerful tool for solving problems that can be broken down into smaller, similar sub-problems.
int fact(int n) {
if (n <= 1) return 1; // Base Case
return n * fact(n-1); // Recursive Step
}The condition where recursion stops. Without it, you get an infinite loop and stack overflow.
The part where the function calls itself with a reduced version of the original problem.
Each recursive call consumes stack memory. Deep recursion or missing base cases can exhaust the stack, crashing your program.