#include "stdio.h"
/*
The following code gives factorial of any give integer
*/
unsigned int factorial(int num)
{
if(num == 1 || num == 0)
return 1;
else
num = num * factorial(num - 1);
}
void main()
{
int y = 5;
/*
Check if the user gives a negative number
*/
if(y < 0)
printf("Factorial of negative numbers doesnot exist");
else
/*
Call the function
*/
printf(" Factorial of %d is %u", factorial(y));
return;
}
Subscribe to:
Post Comments (Atom)
1 comment:
Nice post but do you know how to find factorial of large numbers
Post a Comment