InterviewBit - Greatest Common Divisor
by ne on 2021-09-29 under Algo/DS/Problems tagged with interviewbit
public class Solution {
public int gcd(int A, int B) {
int min=Math.min(A,B);
int gcd=Math.max(A,B);
while(min>0){
if(A%min==0 && B%min==0){
gcd=min;
break;
}
min--;
}
return gcd;
}
}