Greatest common divisor of a and b. Uses Euclidean algorithm.
a
b
int gcd(int a, int b) { int x = a.abs(); int y = b.abs(); while (y != 0) { final int t = y; y = x % y; x = t; } return x; }