#K10921. Greatest Common Divisor Calculation
Greatest Common Divisor Calculation
Greatest Common Divisor Calculation
Given two integers a and b, compute their greatest common divisor (GCD) using the Euclidean algorithm. The algorithm is based on the formula: \(a = bq + r\) where \(r\) is the remainder when a is divided by b, and the GCD of a and b is the same as the GCD of b and \(r\). This process is repeated until the remainder is zero. If both input numbers are zero, the output should be None
.
Note: The input numbers can be negative. In such cases, the absolute values are considered for the GCD computation.
inputFormat
The input consists of a single line containing two space-separated integers, a and b.
outputFormat
Output the greatest common divisor of a and b. If both a and b are zero, output 'None'.## sample
48 18
6
</p>