Largest Coprime Divisor Time : Space : 1234567891011int Solution::cpFact(int A, int B) { int res = -1; for(int i = 1; i <= sqrt(A); i++) { if(A % i) continue; int l = i, r = A / i; if(__gcd(l,B) == 1) res = l; if(__gcd(r,B) == 1) return r; } return res;}