how can i create the formula to calculate n!
Have you tried anything yet?
1 2 3 4 5
|
int fact(int n)
{
if (n <= 0) return 1;
return n * fact(n-1);
}
|
Last edited on
int main()
{
int i, n;
int fact=1;
cout<<"Enter the Value of n:";
cin>>n;
for(i=n ; i>=1 ; i--)
fact = fact*i;
cout<<Factorial: "<<fact;
return 0;
}