/**
Program Name: FINDING FACTORIAL
Description: This Program finds a Factorial of a Given Number
Author: Tauqirul Haque
*/
long fact(long n);
void main()
{
long n;
printf("Enter N : ");
scanf("%d",&n);
if(n < 0) //if its a neg number then changing the sign
{
n = -n;
}
printf("The fact of %ld = %ld \n\n",n,fact(n));
}
long fact(long n)
{
if(n==0 || n==1)
{
return 1;
}
else
{
return n*fact(n-1);
}
}
Program Name: FINDING FACTORIAL
Description: This Program finds a Factorial of a Given Number
Author: Tauqirul Haque
*/
long fact(long n);
void main()
{
long n;
printf("Enter N : ");
scanf("%d",&n);
if(n < 0) //if its a neg number then changing the sign
{
n = -n;
}
printf("The fact of %ld = %ld \n\n",n,fact(n));
}
long fact(long n)
{
if(n==0 || n==1)
{
return 1;
}
else
{
return n*fact(n-1);
}
}
Comments