For int and long, as primitives, not really. For Integer, maybe someone wrote one.
Given that BigInteger is a (mathematical / functional) superset of int, Integer, long and Long, if you need to use these types, convert them to BigInteger, execute GCD and convert the result back.
private static int gcdThing(int a, int b) { BigInteger b1 = BigInteger.valueOf(a); BigInteger b2 = BigInteger.valueOf(b); BigInteger gcd = b1.gcd(b2); return gcd.intValue(); }
Tony Ennis Oct 24 2018-10-24 16:46
source share