37. Greatest Common Divisor
Core1000 ms256 MBSolved by 0%
Read two positive integers and print their greatest common divisor, the largest number that divides both exactly.
Constraints - `1 ≤ a, b ≤ 1000000000`
Input
A single line containing two integers, separated by a space.
Output
Print one integer, the greatest common divisor.
Input12 18
Output6
Noteis a small pair with a shared factor
Input7 13
Output1
Noteis a coprime pair, so the answer is 1
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.