C program to find factorial of a number using recursion

C program to find factorial of a number using recursion


Output:

Enter a number to get its factorial:

5
The factorial of 5 is 120

Implementation:


#include <stdio.h>
int findfact(int n)
{
 if(n==1)
  return 1;
 
 return n*findfact(n-1);
}

int main(void) {
 int n;
 printf("Enter a number to get its factorial:\n");
 scanf("%d",&n);
 printf("The factorial of %d is %d",n,findfact(n));
 return 0;
}