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
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
- #include<stdio.h>
- int main()
- {
- int i;
- int fact=1;
- int number;
- printf("Enter a number: \n");
- scanf("%d",&number);
- for(i = 1; i <= number; i++)
- {
- fact=fact*i;
- }
- printf("Factorial of %d is: %d\n",number,fact);
- return 0;
- }
0 Comments
If you have any doubts, Please let me know