GCD of Two Numbers
hardQuestion 293Read two positive integers a and b from standard input and print their greatest common divisor (GCD), with no trailing newline. For example, for the input 48 36, the GCD is exactly what is shown in Expected Output.
Use the Euclidean algorithm in a loop: repeatedly replace (a, b) with (b, a % b) until b is 0.
Expected output
12= newline. No newline after the last line.
Hints4 available
Sign in to use hintsTopics
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.