Greatest common divisor
The greatest common divisor of two numbers
x
and y
is the largest number that both x
and y
are divisible by.Implement a function
gcd(x, y)
that would return the greatest common divisor of x
and y
.The input contains two numbers
a
and b
.The program should print the result of
gcd(a + 1, b)
, gcd(a, b)
, gcd(a, b + 1)
on separate lines.Input | Output |
3 6 | 2
3
1 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB