// factorial calculator
#include <iostream>
usingnamespace std;
long factorial (long a)
{
if (a > 1)
return (a * factorial (a-1));
elsereturn 1;
}
int main ()
{
int n;
long number = n;
cin>>n;
cout << number << "! = " << factorial (number);
return 0;
}
when I complie it, it shows OK. But when I execute it it shows
// factorial calculator
#include <iostream>
usingnamespace std;
long factorial (long a)
{
if (a > 1)
return (a * factorial (a-1));
elsereturn 1;
}
int main ()
{
int n;
long number = 2;
cout << number << "! = " << factorial (number);
return 0;
}
it worked
thanks.. i will try it for sure.. but what is the reason of "Failed to execute "