最大公约数
public class Test {
public static void main(String[] args) {
int a = 165, b = 55;
System.out.printf("%d 和 %d 的最大公约数是: %d\n", a, b, gcd(a, b));
}
public static int gcd(int a, int b) {
// suppose a > b;
int r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
}