Sign InCreate Account

Upgrade to Pro

Upgrade Now

Coding Workspace

EditorProjectsPractice QuestionsTimed Mock ExamsFlowcharts

PseudoEditor AI

Pseudocode TutorCode GeneratorCode FixerCode Converter
Back to Problems
PreviousNext

Sign in to run tests against edge cases and save your code automatically.

Problem Description

Medium

GCD Function

PROModular Programming
Functions
Euclid's Algorithm

The **greatest common divisor** (GCD) of two positive integers is the largest integer that divides both exactly. Write a function `GCD(a, b)` that returns the GCD using Euclid's algorithm: while `b` is not 0, replace `a` with `b` and `b` with the remainder of `a` divided by `b`. When `b` is 0, the answer is `a`. Then write a main program that inputs two positive integers, calls the function, and outputs the result. For example, the GCD of 12 and 18 is 6.

Example Input

12 18

Example Output

6

Success Rate:

0% (0 passed / 0 attempted)

Code

Draft auto-saved

Test Results

Click "Test Code" to evaluate your code against the tests.

Product

For SchoolsOverviewFeaturesFAQ
PseudoEditor

© 2026 PseudoEditor. All rights reserved.