Here you will get program for factorial in C.

We can find factorial of any number by multiplying it with all the numbers below it.

For example, factorial of 3 will be 6 (3 * 2 * 1).

## Program for Factorial in C

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<stdio.h> int main() { long i,n,fac=1; printf("Enter value of n:"); scanf("%ld",&n); for(i=n;i>=1;--i) fac*=i; printf("\nFactorial of %ld is %ld",n,fac); return 0; } |

**Output**

*Enter value of n:4*

*Factorial of 4 is 24*

Recursion will do as well:

unsigned long long f(int n)

{

if(n==0||n==1) return 1;

else

return n*f(n-1);

}

Yes, this can also be done by using recursive function. Thanks for your comment.