Header Ads Widget

Responsive Advertisement

Factorial Number Using C

#include <stdio.h>
 
long int factorial(int n);
 
void main()
 
{
 
  int n;
 
  printf("Enter the number:");
  scanf("%d", &n);
  printf("Factorial of %d is %d", n, factorial(n));
  
 
}
 
long int factorial(int n)
 
{
 
  if (n <= 1)
 
  {
 
    return (1);
 
  }
 
  else
 
  {
 
    n = n * factorial(n - 1);
    return (n);

  }
}
-------------------------------
@@@@ OUTPUT @@@@

Enter the number: 3
Factorial of 3 is 6

Post a Comment

0 Comments