eolymp
bolt
Try our new interface for solving problems
Problems

GCD of two numbers

GCD of two numbers

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} $$ \InputFile Two integers $a$ and $b~(a, b \le 2 \cdot 10^9)$. \OutputFile Print the GCD of numbers $a$ and $b$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
42 24
Output example #1
6