Recursion
Recursion-09
Recursion-10
Recursion-11
~/algor $ cat problems/rekursiya-ekub-topish
GCD (Euclidean algorithm)
Easy
1000 ms
64 MB
28%
You are given two positive integers $a$ and $b$. Using the recursive Euclidean algorithm, find their greatest common divisor (GCD).
The Euclidean algorithm:
$$\text{GCD}(a, 0) = a$$
$$\text{GCD}(a, b) = \text{GCD}(b, a \pmod b) \quad (b > 0)$$
Input
One line with two integers $a$ and $b$ separated by a space ($1 \le a, b \le 10^9$).
Output
The GCD of $a$ and $b$.
Note
$1 \le a, b \le 10^9$
Examples
Input #1
24 36
Output #1
12
Input #2
17 13
Output #2
1