12 8
For this input, the required output is 4.
4
17 13
For this input, the required output is 1.
1
100 25
For this input, the required output is 25.
25
The greatest common divisor (GCD) of two integers is the largest positive integer that divides both.
Given two integers aaa and bbb, compute gcd(a,b)\gcd(a, b)gcd(a,b).
Note: gcd(0,n)=gcd(n,0)=n\gcd(0, n) = \gcd(n, 0) = ngcd(0,n)=gcd(n,0)=n for any positive nnn.
aba \quad bab
gcd(a,b)\gcd(a, b)gcd(a,b)