programming-examples/c/Recursion/C Program to Factorial using recursion.c
2019-11-15 12:59:38 +01:00

18 lines
302 B
C

#include<stdio.h>
int fact(int);
int main()
{
int num,f;
printf("\nEnter a number: ");
scanf("%d",&num);
f=fact(num);
printf("\nFactorial of %d is: %d",num,f);
return 0;
}
int fact(int n)
{
if(n==1)
return 1;
else
return (n*fact(n-1));
}