# C Program to print factorial of a given number

The Factorial of a number refers to the product of a given series of consecutive whole numbers start with 1 and ending with the specified number

“!”  operator will use for represents the factorial

 #include int main(){   int i,f=1, num;     printf("Enter a number: ");   scanf("%d", &num);     for(i=1;i<=num;i++)     f = f * i;     printf("%d! = %d\n", num, f);   return 0; }

Output:

Enter a number: 5
5! = 120

C program to print Factorial of a given range

 #include int main(){   long f=1;   int i,num,min,max;     printf("Enter a min range: ");   scanf("%d",&min);     printf("Enter a max range: ");   scanf("%d",&max);     printf("Factorial series in given range: ");   for(num=min;num<=max;num++){     f=1;       for(i=1;i<=num;i++)       f=f*i;       printf("%ld ",f);   }     return 0; }

Output

Enter a min range: 2
Enter a max range: 11
Factorial series in given range: 2 6 24 120 720 5040 40320 362880 3628800 39916800

C Program to find the factorial of a given number with recursion function

 #include   int Factorial(int i){   int result = 1;   while (i > 0) {     result = result * i;     i = i-1;   }   return(result); } int main(){   int i,factorial,num;     printf("Enter a natural number: ");   scanf("%d",&num);     factorial = Factorial(num);   printf("%d! = %d\n", num, factorial);     return 0; }

Output

Enter a number to factorial : 12
12! = 479001600