Factorial

Program

#include <stdio.h>

int Factorial (int n);

int main()
{
   int fact, n;

   printf("Enter a positive integer : ");
   scanf("%d", &n);

   fact = Factorial(n);
   printf("%d\n", fact);

   return 0;
}

/*************************
* Factorial() finds the factorial of the number, 
* n, passed in using recursion.  
*
* Input: The integer n to find the factorial of
* Output: Returns n!
************************/
int Factorial (int n)
{
   if (n == 0) 
   {
      return (1);
   }
   else 
   {
      return (n * Factorial (n - 1));
   }
}


Last Modified -