C program to find factorial of a number using "Recursion".

Recursion in C

/* C program to find factorial using recursion*/
#include <stdio.h>
#include <conio.h>
int factorial(int n)
{
if(n <= 1)
{
return 1;
}
return n * factorial(n - 1);
}
int  main()
{
int n;
printf("Enter any number:");
scanf("%d",&n);
printf("Factorial of %d is=%d\n", n, factorial(n));
getch();
}
Recursion in C


Expected Output:
Enter any number: 5
Factorial of 5 is= 120


Post a Comment

Previous Post Next Post