一个简单的小算法来获取两个数的最大公约数,
public class Test {
public static void main(String[] args) {
long result = gcd(15, 3);
System.out.println(result);
} public static long gcd(long m, long n) {
while (n != 0) {
long rem = m % n;
m = n;
n = rem;
}
return m; }
}
2023-07-17 09:56:52
一个简单的小算法来获取两个数的最大公约数,
public class Test {
public static void main(String[] args) {
long result = gcd(15, 3);
System.out.println(result);
} public static long gcd(long m, long n) {
while (n != 0) {
long rem = m % n;
m = n;
n = rem;
}
return m; }
}