Greatest Common Divisor

EasyMath

Description

Given two positive integers a and b, return their greatest common divisor.

Examples

Input:a = 12, b = 18
Output:6
Explanation:

The greatest number dividing both 12 and 18 evenly is 6.

Input:a = 7, b = 13
Output:1
Explanation:

The greatest number dividing both 7 and 13 evenly is 1.

Input:a = 100, b = 75
Output:25
Explanation:

The greatest number dividing both 100 and 75 evenly is 25.

Constraints

  • 1 ≤ a, b ≤ 10⁹

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.