/* Factorial : Factorial of n is the product of all positive descending integers. */
#include <stdio.h>
int fact(int);
int main()
{
int n, i, x, a = 1;
printf("Enter a number whose factorial you want: ");
scanf("%d", &n);
x = fact(n);
printf("Factorial of %d is %d.", n, x);
return 0;
}
int fact(int m){
if (m == 0)
return 1;
else
return(m*fact(m-1));
}
Comments
Post a Comment