Check this piece of code


int gcd(int a, int b){
return a;
return(b, a%b);
int Solution::cpFact(int A, int B) {
int x=gcd(A,B);
return A;
return cpFact(A/x,B);
//return x;

Tell me why this wasn’t working?


Your approach is correct and it works.


u have to return gcd(b,a%b) but u just wrote (b,a%b)