Computes the greatest common divisor (gcd).