//this is a program to find the factorial of a number using the recursive function
#include<stdio.h>
#include<conio.h>
long int fact(int n);
void main()
{
long int f;
int num;
printf("\n\nEnter the number: ");
scanf("%d",&num);
f=fact(num);
printf("\n\nFactorial Using Recursion: ");
printf("\n\nFactorial=%ld",f);
getch();
}
long int fact(int n)
{
long int f;
if(n==1)
return 1;
else
{
f=fact(n-1)*n;
return f;
}
}
#include<stdio.h>
#include<conio.h>
long int fact(int n);
void main()
{
long int f;
int num;
printf("\n\nEnter the number: ");
scanf("%d",&num);
f=fact(num);
printf("\n\nFactorial Using Recursion: ");
printf("\n\nFactorial=%ld",f);
getch();
}
long int fact(int n)
{
long int f;
if(n==1)
return 1;
else
{
f=fact(n-1)*n;
return f;
}
}