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();
}
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();
}