第七章第十四题(计算gcd)(Calculate GCD)
-
7.14(计算gcd)编写一个方法,返回个数不确定的整数的最大公约数。给定方法头如下所示:
public static int gcd(int … numbers)
编写一个测试程序,题数用户输入5个数字,调用该方法找出这些书的最大公约数,并且显示这个最大公约数。
7.14(Calculate GCD)Calculate GCD write a method, return the number of uncertain integer of the greatest common divisor. The given method header is as follows:
public static int gcd(int … numbers)
Write a test program, the user input 5 numbers, call this method to find the greatest common divisor of these books, and display the maximum common divisor. -
参考代码:
package chapter07; import java.util.Scanner; public class Code_14 { public static void main(String[] args) { int