#K74372. Computing the Greatest Common Divisor (GCD)
Computing the Greatest Common Divisor (GCD)
Computing the Greatest Common Divisor (GCD)
This problem requires you to compute the greatest common divisor (GCD) of two non-negative integers using the Euclidean algorithm. The GCD of two integers \(a\) and \(b\), denoted as \(\gcd(a,b)\), is defined as the largest positive integer that divides both \(a\) and \(b\) without leaving a remainder.
Your task is to implement a function that reads two integers from standard input and prints their GCD to standard output.
For example, given the input 8 12
, your program should output 4
.
inputFormat
The input is provided via standard input. It consists of a single line containing two integers separated by space:
a b
where \(a\) and \(b\) are non-negative integers.
outputFormat
Output the greatest common divisor of the two given integers to standard output.
GCD## sample
8 12
4