public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int res = gcd(8, 6);
System.out.println(res);
}
private static int gcd(int i, int j) {
int m, n, r;
// 使m>n
if (i > j) {
m = i;
n = j;
} else {
m = j;
n = i;
}
// 通过辗转除来求的最大公约数
r = m % n;
while (r != 0) {
m = n;
n = r;
r = m % n;
}
// 返回最大公约数
return n;
}
}