Runtime error can't find the uncaught exception


#1

int gcd(int n1, int n2){
n1 = ( n1 > 0) ? n1 : -n1;
n2 = ( n2 > 0) ? n2 : -n2;

while(n1!=n2)
{
    if(n1 > n2)
        n1 -= n2;
    else
        n2 -= n1;
}
return n1;

}
int Solution::cpFact(int A, int B) {
int i, l = (int)sqrt(A),n;
vector factor;
for(i=2;i<=l;i++){
if(A%i == 0){
factor.push_back(i);
}
}
l = factor.size();
int x = factor[l-1];
for(i=l-1;(x < A/factor[i]);i–){
n = A/factor[i];
factor.push_back(n);
}
factor.push_back(A);
l =factor.size();
for(i = l-1;i>=0;i–){
n = gcd(factor[i],B);
if(n == 1){
return factor[i];
}
}
return 1;

}

Code runs perfectly on personal IDE but shows runtime error in InterviewBit please point out the mistake