#include <stdio.h>
unsigned long factorial(unsigned long);
int main(void)
{
unsigned long number = 0L;
printf("\nEnter an integer value: ");
scanf(" %lu", &number);
printf("\nThe factorial of %lu is %lu\n", number, factorial(number));
return 0;
}
unsigned long factorial(unsigned long n)
{
if(n < 2L)
return n;
else
return n*factorial(n - 1L);
}
No comments:
Post a Comment