C Programming - Recursion Sample (Number Factorial)steemCreated with Sketch.

in hive-175254 •  3 years ago  (edited)
#include <stdio.h>

unsigned long long int factorial(unsigned int i) {

   if(i <= 1) {
      return 1;
   }
   return i * factorial(i - 1);
}

int  main() {
   int i = 12;
   printf("Factorial of %d is %d\n", i, factorial(i));
   return 0;
}

Output : Factorial of 12 is 479001600

Please Vote this post if you like it.
Please Follow me if you like my posts.
If you have any questions about this post, ask in comments.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

You've got a free upvote from witness fuli.
Peace & Love!

Loading...