DEV Community

Cover image for C - Recursion
Haile Melaku
Haile Melaku

Posted on

1

C - Recursion


#C - Recursion

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

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

int main() {
   recursion();
}
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.

Example

Creating a recursive function to find the factorial of a number

Image description
Output

Image description

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more