C Armstrong NumberC Average of N NumbersC Biggest of Three NumbersC Common DivisorsC Composite NumberC Condense a NumberC Even NumberC Factorial of a NumberC Fibonacci SeriesC GCDC LCMC Leap YearC Multiplication TableC Number CombinationC Odd NumberC Palindrome NumberC Perfect NumberC Prime FactorC Prime NumberC Sum of DigitsC Swapping Two Numbers

C Array ProgramsC Converter ProgramsC Star Patterns ProgramC Number Patterns ProgramC Alphabet Patterns ProgramThe factorial of a number n can be defined as the product of all positive numbers less than or equal to n. For example, the factorial of 6 is 1 × 2 × 3 × 4 × 5 × 6 = 720.

The following table provides few examples of factorial of a number.

Number | Factorial | Result |
---|---|---|

1! | 1 | 1 |

2! | 1 × 2 | 2 |

3! | 1 × 2 × 3 | 6 |

4! | 1 × 2 × 3 × 4 | 24 |

**Note**: In Mathematics, factorial of a number is represented by exclamation mark.

**Tips**: It is recommended to use our online Factorial of a Number calculator for better understanding.

In the following example, we will find a factorial of a number 6.

C Compiler

#include <stdio.h>
int main()
{
int num = 6;
int i = 1;
int factorial = 1;
for(i=1; i<=num; i++)
factorial *= i;
if(num)
printf("Factorial of %d: %d", num, factorial);
else
printf("Factorial of 0: 0");
return 0;
}

In the following example, we will find a factorial of any given number.

C Compiler

#include <stdio.h>
int main()
{
int num;
int i = 1;
int factorial = 1;
printf("Enter a (int) number: ");
scanf("%d", &num);
for(i=1; i<=num; i++)
factorial *= i;
if(num)
printf("Factorial of %d: %d", num, factorial);
else
printf("Factorial of 0: 0");
return 0;
}

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.