用Java语言写一个getGCD函数
public class GCD { public static int getGCD(int a, int b) { if (b == 0) { return a; } else { return getGCD(b, a % b); } }
public static void main(String[] args) {
int a = 15;
int b = 25;
System.out.printf("The GCD of %d and %d is %d\n", a, b, getGCD(a, b));
}
}
原文地址: https://www.cveoy.top/t/topic/wLs 著作权归作者所有。请勿转载和采集!