## C Program To Find Factorial of Number

Learn How To Find Factorial of Number in C Programming Language. It is important that we should know about** How A For Loop Works **before getting further with the C Program Code. This Code is described with an Explanation of Factorial Program in C Language. We have used Recursion method as well as the While and For Loops in the following Factorial Programs.

#### What is a Factorial of a Number?

A Factorial for a Non-Negative Integer is the Product of all the Positive Integers Less than or Equal to that Number. The Factorial Notation is used in Combinatorics, Permutations, Algebra and other Mathematical Analysis.

#### Example

**5! = 5 * 4 * 3 * 2 * 1 = 120**

One interesting thing to note here is that the value of **0! = 1**.

**Must Read: C Program To Find Factorial of Large Numbers**

#### Method 1: Calculate Factorial of Number in C with While Loop

[crayon-5c0d99948bc35055934557/]

**Must Read: C Program To Display Fibonacci Series**

#### Method 2: C Program To Find Factorial of a Number using For Loop

[crayon-5c0d99948bc3e128749433/]

**Must Read: C Program To Find Greatest Common Divisor of Two Numbers**

#### Method 3: C Program To Calculate Factorial using Recursion Method

[crayon-5c0d99948bc42754952672/]

**Must Read: C Program To Calculate Value of nPr in Probability**

#### Output

If you have any compilation errors or doubts in this C Program To Find Factorial of Number , let us know about in the Comment Section below. Find more information about the Factorial of a Number in this **Wikipedia** article.

Thanks for so many ways to solve factorial program in c programming. Helped to match differences between for and while loops.

You’re welcome Dipak! Our main aim was to make the readers understand Factorial of a Number C Program effectively using comparison!!

I finally learnt how to convert a For Loop into a While Loop in C Programming.

Can we use separate funtion to write factorial program in C language?

Can we make a library function for factorial of a number c program which cam be used by including header files?

Can we find Factorial of a very large integer number using the same code above?

No. A large integer will require a datatype having larger range than just an

int. This code is sufficient only for finding factorial of a normal number.Please provide Factorial of Large Numbers in C Programming.

This program for factorial can contain one additional if loop. Since, the factorial of 1! is 1 and the factorial of 0! is 1, it needs to be implemented in this factorial code too.

if(n == 0 || n == 1)

{

fact = 1;

}

Best explanation of the factorial of a number in C programming. This has cleared my concepts and especially the loops in C.