Java greatest common divisor and least common multiple code