Basic CPP solution


#1

int Solution::gcd(int A, int B) {
int n = min(A,B);
int m = max(A,B);
if(n==0) return m;
for(float i=n;i>0;i–){
float x = n/i;
if(x==(int)x){
float y = m/i;
if(y==(int)y) return i;
}
}
}