Question: how to find a greatest common divisor in java?
Answer: gcd(0, 0) = 0, gcd(n1, 0) = n1, gcd(0, n2) = n2. When n1 and n2 are both even integers, then gcd(n1, n2) = 2 * gcd(n1/2, n2/2), since 2 is the common divisor.