PROGRAM TO CALCULATE FACTORIAL BY RECURSION METHOD
10:54 PM
Auther Suman Thapa
#include<conio.h>
#include<stdio.h>
long int factorial(int);
int main()
{
int i,n,y,x,result;
printf("\nEnter the number");
scanf("%d",&n);
result=factorial(n);
printf("\nFactorial of %d is %d",n,factorial(n));
getch();
}
long int factorial(int n)
{
int y;
if(n==0)
return(1);
int x=n-1;
y=factorial(x);
return(n*y);
}
#include<conio.h>
#include<stdio.h>
long int factorial(int);
int main()
{
int i,n,y,x,result;
printf("\nEnter the number");
scanf("%d",&n);
result=factorial(n);
printf("\nFactorial of %d is %d",n,factorial(n));
getch();
}
long int factorial(int n)
{
int y;
if(n==0)
return(1);
int x=n-1;
y=factorial(x);
return(n*y);
}
0 comments: