#include <iostream>
using namespace std;
int fact(int n);
int main()
{
int n;
cout<< "Enter the number: ";
cin>> n;
cout<< "Factorial of " <<n <<" is " <<fact(n);
}
int fact(int n)
{
if (n>=1)
return n*fact(n-1);
else
return 1;
}
#include <iostream>
using namespace std;
int fact (int);
int main()
{
cout << " Please enter your number = ";
int n ;
cin >> n ;
cout << " Answer is = " << fact (n) << endl;
return 0;
}
int fact (int n )
{
if (n <= 1)
return 1;
return n * fact (n-1);
}
/*#include<bits/stdc++.h>
using namespace std;
iterative solution:
int fact (int n, int k)
{
if(n==0) return 1;
return fact(n-1,k*n);
}
int main()
{
int n,k=1;
cin>>n;
int ans=fact(n,k);
cout<<ans<<endl;
}*/
//recursive solution.
#include<bits/stdc++.h>
using namespace std;
int fact(int n)
{
if(n==0)return 1;
return n*fact(n-1);
}
int main(){
int n;
cin>>n;
cout<<fact(n)<<endl;
}