Recursion Program in C

Factorial program in c using recursion:

Recursion is a technique in which a function calls itself, for example in above code factorial function is calling itself.


long factorial(int);

int main()
int n;
long f;

printf(“Enter an integer to find factorial\n”);
scanf(“%d”, &n);

if (n < 0)
printf(“Negative integers are not allowed.\n”);
f = factorial(n);
printf(“%d! = %ld\n”, n, f);
return 0;

long factorial(int n)
if (n == 0)
return 1;
return(n * factorial(n-1));



12 Replies to “Recursion”

  1. Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your blog? My blog is in the exact same area of interest as yours and my users would certainly benefit from a lot of the information you provide here. Please let me know if this okay with you. Thanks a lot!|

  2. We’re a group of volunteers and starting a brand new scheme in our community. Your web site offered us with helpful info to work on. You’ve done a formidable job and our entire community can be grateful to you.

  3. Greetings! Very helpful advice in this particular article! It is the little changes that produce the most significant changes. Thanks for sharing!

  4. It’s actually a great and useful piece of info. I’m glad that you simply shared this useful info with us. Please stay us up to date like this. Thanks for sharing.

  5. Thank you for the sensible critique. Me & my neighbor were just preparing to do some research about this. We got a grab a book from our local library but I think I learned more clear from this post. I am very glad to see such excellent info being shared freely out there.

  6. I don’t even know how I finished up right here, however I believed this submit used to be great. I do not recognize who you might be however certainly you’re going to a famous blogger in case you aren’t already 😉 Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *