# why I am getting this RE (SIGFPE) Error

#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll fact(ll n);

ll nCr(ll n, ll r)
{ if(fact(r)*fact(n-r) == 0) return 0;
return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
ll fact(ll n)
{
ll res = 1;
for (ll i = 2; i <= n; i++)
res = res * i;
return res;
}

ll Solve(ll arr[], ll n){
if(n < 1) return 0;
int n1 = 0,n2 = 0;
int ans = 0,ans1 = 0, ans2 = 0;
for(ll i = 0; i < n; i++){
if(arr[i]>0){
n1++;
}
if(arr[i]<0){
n2++;
}
}
if(n1>1){
ans1 = nCr(n1,2);
}
if(n2>1){
ans2 = nCr(n2,2);
}
ans = ans1 + ans2;
return ans;
}
int main(){
int t;
cin>>t;
while (tâ€“)
{
ll n;
cin>>n;
ll arr[n];
for(ll i = 0; i < n;i++){
cin>>arr[i];
}
cout<<Solve(arr,n)<<endl;
}

``````return 0;
``````

}

Hey @ashutrox ,
Your code logic is correct but your NCR implementation is wrong also as you know C++ only stores <=1018 number but your ncr(n,r) is doing undefined behaviour because fact function can take numbers <= 10^5 and its factorial is huge even 20! is 10^18 and that is a reason.