GCD of two numbers
128 megabytes
Find the GCD (greatest common divisor) of two nonnegative integers.
GCD(a, b) = \begin{cases}
a, b = 0 \\
b, a = 0 \\
GCD(a~mod~b, b), a \ge b \\
GCD(a, b~mod~a), a < b
\end{cases}
Input
Two integers a and b~(a, b \le 2 \cdot 10^9).
Output
Print the GCD of numbers a and b.