Algorithmic problemElementary20 XPExercise 8/16

Greatest common divisor

Task

The program reads two positive whole numbers (each on its own line) and prints their greatest common divisor.

The numbers may have 10 digits, so trying every divisor one by one would take far too long - use Euclid's algorithm. Do not use the built-in math.gcd.

Examples

  • Input

    12
    18

    Expected output

    6

Rules

  • Do not use math.gcd - work it out yourself.

After you submit, 5 hidden tests will also check your solution: coprime numbers, 100 and 75, equal numbers, the classic example, 10-digit numbers.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.