src/org/kocakosm/pitaya/math/Numbers.java
public static int gcd(int a, int b)
	{
		try {
			if (a < 0 || b < 0) {
				return gcd(safeAbs(a), safeAbs(b));
			}
			return (int) gcd((long) a, (long) b);
		} catch (ArithmeticException e) {
			throw new ArithmeticException(
				"Int overflow: gcd(" + a + ", " + b + ")");
		}
	}
public static int gcd(int a, int b)
	{
		try {
			if (a < 0 || b < 0) {
				return gcd(safeAbs(a), safeAbs(b));
			}
			return (int) gcd((long) a, (long) b);
		} catch (ArithmeticException e) {
			throw new ArithmeticException(
				"Int overflow: gcd(" + a + ", " + b + ")");
		}
	}
Returns the greatest common divisor of the absolute value of the
given two numbers. This method first computes the absolute values of
the given numbers, thus it doesn't accept {@code Integer.MIN_VALUE}.
Also, note that if one of the given values is {@code 0}, this method
will return the absolute value of the second argument.
This method implements the binary GCD algorithm (also known as
Stein's algorithm). For further information on this algorithm, please
refer to <a href="http://en.wikipedia.org/wiki/Binary_GCD_algorithm">
Wikipedia</a>.

@param a the first number.
@param b the second number.

@return the greatest common divisor of {@code a} and {@code b}.

@throws ArithmeticException if {@code a} or {@code b} is equal to
{@code Integer.MIN_VALUE}.