All problems

GCD of Two Numbers

easyPythonMath

A framing shop has two rolls of edging tape, one of each length given, and wants to cut both rolls into equal pieces with nothing left over on either roll. Longer pieces mean fewer joins, so the shop wants the longest piece length that works for both rolls. That length is the greatest common divisor of the two numbers.

Task: Read the two roll lengths and print the greatest common divisor.

Input

A single line holding two positive integers separated by a single space, each between 1 and 1,000,000,000.

Output

One line holding a single integer: the largest whole number that goes into both lengths exactly.

Example:

Input:
12 18

Output:
6

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…