CJCoding With Joseph

GCD of Two Numbers

Read 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:

12

Use the Euclidean algorithm in a loop: repeatedly replace (a, b) with (b, a % b) until b is 0.

Expected Output:

12
Topics:
Loops
๐Ÿ“ฅ Auto-Input:
48 36
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.