Calculate Factorial by Using Recursion

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

* Calculate factorial by using recursion */

#include
#include

int fact(int k)
{
if(k==0)
return 1;
else
return k*fact(k-1);
}

void main()
{
int n;
clrscr();
printf("\n Enter a number :");
scanf("%d",&n);
printf("\n Factorial value=%d",fact(n));
getch();
}

You might also like