Program factorial using recursion

Program factorial using recursion

Program factorial using recursion
Ganesh
Tuesday, 22 November 2016

Factorial of a number using recursion:-


#include<stdio.h>
#include<conio.h>
int recu (int x);
void main()
{
clrscr();
int n, fact;
printf ("Enter The Number:");
scanf ("%d",&n);
fact=recu(n);
printf ("%d",fact);
getch();
}
int recu (intx)
{
intf;
if(x==1)
return 1;
else
{
f=x*recu(x-1);
}
return(f);
}

Output:-
Enter The Number: 7
5040