[Solved] compute the greatest common divisor of four numbers [closed]
As David Conrad said GCD(a, b, c, d) = GCD(a, GCD(b, GCD(c, d))) You can use java.math.BigInteger class as below : public static void main(String[] args) { int [] nums = {4,8,16,24}; int gcd = nums[0]; for (int i=1 ; i<nums.length; i++) { gcd = Getgcd(gcd,nums[i]); } System.out.println(“The GCD of your n numbers is “+ … Read more