I need Answers -_-


#1

Why Commented Code gives TLE, anyone ? please explain.
int gcd(int a, int b) {
if(b == 0) return a;
return gcd(b, a%b);
}
int Solution::cpFact(int A, int B) {
// for(int x=A;x>=1;x–){
// if(A%x==0 && gcd(x,B)==1){
// return x;
// }
// }
// return 1;
int i = A, j = 1;
while(i > 1) {
if(not(A%j)) {
i = A/j;
if(gcd(i, B) == 1) return i;
}
j++;
}
return 1;
}