Factorial Program in C / Find factorial using Recursion

Education & Competitive Exam

| 430 views

Factorial Program in C / Find factorial using Recursion
⏱ Estimated reading time: 2 min

What is Factorial?

In Mathematics, factorial is a simple thing. Factorials are just products. An exclamation mark indicates the factorial. Factorial is a multiplication operation of natural numbers with all the natural numbers that are less than it. In this article, let’s discuss the factorial definition, formula and examples.

The formula to find the factorial of a number is

n! = n × (n-1) × (n-2) × (n-3) × ….× 3 × 2 × 1

Factorial of 10

For example, the factorial of 10 is written as

10! = 10 (9 × 8 × 7 × 6 × 5× 4 × 3 × 2 × 1)

Therefore, the value of 10 factorial is 3,628,800


How to find factorial in C using loog

    #include  
    int main()    
    {    
     int i,fact=1,number;    
     printf("Enter a number: ");    
      scanf("%d",&number);    
        for(i=1;i<=number;i++){    
          fact=fact*i;    
      }    
      printf("Factorial of %d is: %d",number,fact);    
    return 0;  
    }  

Find factorial in C using Recursion

#include
int main(){
int n;
long int fact(int n);
printf("Enter Your number :");
scanf("%d",&n);

printf("The factorial of %d is %ld",n,fact(n));
return 0;
}

long int fact(int n){
       if(n>=1){
             return n*fact(n-1);
        }else{
             return 1;
       }
}

OUTPUT :

Enter a number: 5
Factorial of 5 is: 120


CONCLUSION :

There are multiple methods to calculate the factorial of a number in C. Whether it's using an iterative solution, recursion, the tgamma() method, or pointers, the most suitable method will depend on the specific needs of your program.




🔒 Some advanced sections are available for Registered Members
Register Now

🚀 Ready to Boost Your Exam Preparation?

Practice topic-wise quizzes based on these facts and improve your GK, Science & Current Affairs for competitive exams.

Perfect for SSC, UPSC, Railway, Banking & State Exams.

👉 Start Free Quiz Now
Share this Post
About the Author

✍️ Quizer Team is a passionate team of educators and software professionals behind Quizer.in . We specialize in creating high-quality quizzes and learning resources for competitive exams, academics, IT & software, and skill development. Our mission is to make learning interactive, practical, and enjoyable—helping students build knowledge, confidence, and real-world skills.

Comments

No comments yet — be the first to comment! 💬
Leave a Comment

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

Popular Competitive Exam Quizzes