[java] Java: get greatest common divisor