Java Find the greatest common divisor of two positive integers. The integers can be large, so you need to find a clever solution.
import static java.math.BigInteger.valueOf;
import java.math.BigInteger;
public class GCD {
public static int compute(int x, int y) {
return valueOf(x).gcd(valueOf(y)).intValue();
}
}
Code language: Java (java)