SDE Path

GCD of Two Numbers Recursively

Easy

GCD of Two Numbers Recursively

Find the greatest common divisor with the recursive Euclidean algorithm.

Input format

A single line with two integers A and B (0 <= A, B <= 1000000000, not both zero).

Output format

Print the greatest common divisor (GCD) of A and B.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
12 18
Expected output
6
Example 2
Input
48 36
Expected output
12