#include<iostream>
#include<conio.h>
using namespace std;
long int fact(int n);
int main()
{
int num;
cout<<"Enter any number to find out it's factorial : ";
cin>>num;
cout<<"\n\nThe factorial of "<<num<<" is "<<fact(num);
getch();
return(0);
}
long int fact(int n)
{
if(n==0)
return(1);
else
return(n*fact(n-1));
}
No comments:
Post a Comment