Greatest Common Divisor of Two Integers
Find the greatest common divisor of two integers. The result is the largest positive whole number that divides both inputs evenly.
Formula & assumptions
gcd(a,b) = gcd(b, a mod b)
Signs do not affect the divisor. The algorithm uses Euclidean remainders.
Worked example
- First integer
- 84
- Second integer
- 30
- GCD
- 6
Interpreting the result
Divide each input by the GCD to remove every factor the two numbers share.