Factorial of n is the product of all positive descending integers. Factorial of n is denoted by n!. For example:
5! = 5*4*3*2*1 = 120
3! = 3*2*1 = 6
Here, 5! is pronounced as "5 factorial", it is also called "5 bang" or "5 shriek".
The factorial is normally used in Combinations and Permutations (mathematics).
/* To find factorial of a integer */
#include<math.h>
#include<stdio.h>
int main()
{
int n, i, fact=1;
printf("Enter the No.:");
scanf("%d", &n);
for (i=1;i<=n;i++)
fact=fact*i;
printf("\n The factorial of %d is : %d\n", n,fact);
return(0);
}
#include<math.h>
#include<stdio.h>
int main()
{
int n, i, fact=1;
printf("Enter the No.:");
scanf("%d", &n);
for (i=1;i<=n;i++)
fact=fact*i;
printf("\n The factorial of %d is : %d\n", n,fact);
return(0);
}
Comments
Post a Comment