Pseudocode Compiler
Practice

Greatest Common Divisor

HARDAlgorithms

Read two positive integers. Output their Greatest Common Divisor (GCD) using the Euclidean algorithm.

Input: Two positive integers on separate lines. Output: The GCD.

Example:

Input:  12
        8
Output: 4
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: GCD(12, 8)
Inputs: 12, 8
Expected: 4
Test 2: GCD(100, 75)
Inputs: 100, 75
Expected: 25
Test 3: Coprime
Inputs: 7, 13
Expected: 1
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade