#include <stdio.h>
#include <conio.h>
long fact(int);
main()
{
int n;
long f;
printf("\n enter a number");
scanf("%d",&n);
f = fact(n);
printf("\n Factorial of %d is %ld",n,f);
getch();
}
long fact(int n)
{
int m;
if (n==1)
return n;
else
{
m = n*fact(n-1);
return m;
}
}
No comments:
Post a Comment