#include<stdio.h>
int fact(int );
int main()
{
long int a,res;
printf("Enter any number to calculate its factorial:\t");
scanf("%ld",&a);
res=fact(a);
printf("\nFACTORIAL IS:\t %ld",res);
getch();
return 0;
}
int fact(int a)
{
if(a==0||a==1)
return 1;
if(a>=2)
return a*fact(a-1);
}
0 Comments