Why I'm getting runtime error?

#include

using namespace std;

int factorial (int temp);

int main()
{
    int n,t;
    long long int q;
    cin>>t;
    while(t--)
    {
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>q;
    int a=factorial(n);
    int b=factorial(n-2);
    b=b*2;
    //if(n!=1)
    cout<<(a/b);
    //else cout<<1;
    }
return 0;
}
int factorial(int temp)
{
    int n=2,ans=1;
    if(temp<2)
    return 1;
    while(temp>=n)
    {
    ans=ans*n;
    cout<<"ans="<<ans<<endl;
    n++;
    }
return ans;
}

why i’m i getting runtime() error???

There are compilation errors in your code, remvove them first!!

The header files should be included using the #include keyword. Also clean up your code a bit. There are a lot of compilation errors too like b2 not defined.
Fix these issues and you should be good to go :slight_smile:

Int has a range of 10^9 u can compute around 14 factorial anythng above would give you WA for sure .As for runtime error which runtime error? If its floating point error check if b doent doesnt become 0 coz of d above reason.

//