C Program to Find Factorial of a Number | Factorial Program in C

 

C program to find the factorial number.

What is Factorial ?

n! "n factorial"
If n is a positive integer, then n! is nmultiplied by all of the smaller positive integers.
0! = 1 
1! = 1 
2! = (2)(1) = 2 
3! = (3)(2)(1) = 6 
4! = (4)(3)(2)(1) = 24 
5! = (5)(4)(3)(2)(1) = 120 
6! = (6)(5)(4)(3)(2)(1) = 720
    1. #include<stdio.h>
    2. int main()
    3. {
    4.    int i;
    5.    int fact=1;
    6.    int number;
    7.    printf("Enter a number: \n");
    8.    scanf("%d",&number);
    9.              for(i = 1; i <= number; i++)
    10.                     {
    11.                        fact=fact*i;
    12.                     }
    13. printf("Factorial of %d is: %d\n",number,fact);
    14. return 0;
    15. }

Post a Comment

0 Comments