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