a concise shot of dev knowledge
Become a Contributor
Concise shots of dev knowledge


recursive function

What is recursion?

Edpresso Team

Recursion is a widely used phenomenon in computer science used to solve complex problems by breaking them down into simpler ones. Recursion is a process by which a function calls itself directly or indirectly. The corresponding function is called as recursive function.

Using recursive algorithms, certain complex problems can be solved quite easily.

svg viewer

What is a base condition in recursion?

In a recursive function, the solution to the base case is provided and the solution of the bigger problem is expressed in terms of smaller problems.

The role of the base condition is to stop a recursive function from executing endlessly – once a pre-specified base condition is met, the function knows it’s time to exit.