Calculates the greatest common divisor and least common multiple.