# How to find Factorial of any number in C language

By | June 17, 2021

In this tutorial, we are going to learn How to find Factorial of any number in the C language

What is the factorial of a number?
In mathematics, We can say that the factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n

For example,

4! = 4*3*2*1 = 24
6! = 6*5*4*3*2*1 = 720

Here, 4! is pronounced as “4 factorial”,

The factorial is normally used in Combinations or we can say in other word is mathematics
There are different ways to write the factorial program in c language program. we can see the 3 ways to write the factorial(!) program.

1.Using for loop
2.Using while loop
3.Using Recursion

1.Using for loop

The output of the above program :

Enter zero(O) or Positive number:
5
Finding Factorial of 5
Factorial of 5 = 120

2.Using while loop

Few Input & output of the above program:

Enter a Number :0
Factorial of 0 is 1

Enter a Number:5
Factorial of 5 is 120

Enter a Number:-3
Enter valid Number Input number should be either zero or a positive number

3.Using recursion

The output of the above program :

Enter a Number: 6

Factorial of 6 is 720

In this post, we learned about How to find Factorial of any number in the C language

You May Also Like:

Swapping of two numbers in C Language by using a temporary variable

Thank you for visiting.
If you have any feedback or suggestion please drop in below the comment box.

Category: C