#include<stdio.h>
#include<conio.h>
void main(){
long int n,ans;
long int factorial(long int x);
printf("Enter an integer number\n");
scanf("%ld",&n);
ans=factorial(n);
printf("factorial of %ld=%ld\n",n,ans);
getch();
}
long int factorial(long int x){
if (x==1) return 1;
else return (x*factorial(x-1));
}
No comments:
Post a Comment