#K50617. Greatest Common Divisor

    ID: 28905 Type: Default 1000ms 256MiB

Greatest Common Divisor

Greatest Common Divisor

Given two integers x and y, compute their greatest common divisor (GCD). The GCD of two integers is the largest positive integer that divides both numbers without leaving a remainder. Mathematically, it can be defined as: \(\gcd(x,y)=\max\{d \mid d\,|\,x \text{ and } d\,|\,y\}\).

You are required to use the efficient Euclidean algorithm to solve this task.

inputFormat

The input consists of a single line containing two space-separated integers x and y.

outputFormat

Output a single integer representing the greatest common divisor of x and y.## sample

48 18
6