DEV Community

Cover image for C - Recursion
Haile Melaku
Haile Melaku

Posted on


C - Recursion

#C - Recursion

Recursion is a method of calling a function inside a function iteratively.

void recursion() {
   recursion(); /* function calls itself */

int main() {
Enter fullscreen mode Exit fullscreen mode

In this case the function recursion calls a copy of itself to work on a smaller problem until some conditional is satisfied.

Any function which calls itself is called recursive function, and such function calls are called recursive calls.

Recursion is a method of solving problems based on the divide and conquer mentality and we break the problem into much smaller sub part's of itself, one of the subpart consists the a conditional to break the recursion.


Creating a recursive function to find the factorial of a number

Image description

Image description

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git