#include<stdio.h>
long int fact(long int);
int main()
{
long int n,k=1;
clrscr();
printf("Enter the number:");
scanf("%ld",&n);
k=fact(n);
printf("Factorial is: %ld",k);
getch();
return 0;
}
long int fact(long int n)
{
long int f=1;
if(n==0)
return 1;
else
f=n*fact(n-1);
return f;
}
Output:
Enter the number: 10
Factorial is: 3628800
No comments:
Post a Comment