fb pixel

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 that number.
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
3 6

Output
2
3
1
 
To check your solution you need to sign in
Sign in to continue