Divisibility and the Euclidean algorithm
Find greatest common divisors by preserving common divisors while shrinking a remainder problem.
On this page
The question for today
What you’ll understand
- Translate divisibility into an integer equation with an explicit witness.
- Prove that one remainder step preserves every common divisor.
- Compute a greatest common divisor and justify termination.
Integer arithmetic becomes more revealing when division is treated as a question rather than an operation that always succeeds. Can a collection of identical packets fit a total exactly? Which packet sizes fit two totals simultaneously? These are divisibility questions, and the Euclidean algorithm answers the second without first discovering either prime factorization. Its central idea is to replace a difficult pair by a smaller pair with exactly the same common divisors. We will track that invariant instead of memorizing a succession of long divisions.
Divisibility is an existence statement
For integers a and b, saying that a divides b means there is an integer k with b = ak. The witness k matters: 4 divides 20 because 20 = 4 × 5, whereas 4 does not divide 22. Every nonzero integer divides zero, but zero divides only zero. In this lesson the greatest common divisor is defined for pairs not both zero and is always chosen positive.
A common divisor divides each member of a pair. If it divides a and b, it also divides every integer combination ua + vb: substitute a = dr and b = ds, then factor out d. This closure under subtraction explains the algorithm. Notice that a common divisor need not divide the quotient a/b as an integer; introducing fractions would change the problem and discard the structure we need.
A remainder preserves the answer
When b is positive, division with remainder gives a unique pair q and r with a = qb + r and zero at most r less than b. Any divisor of a and b divides r = a − qb. Conversely, any divisor of b and r divides a = qb + r. The sets of common divisors therefore agree in both directions. This is stronger than merely noticing that one particular divisor survives.
Apply the same step to b and r until a remainder is zero. Each nonzero remainder is a smaller positive integer than its predecessor, so the procedure cannot continue forever. At the last step the positive member divides the zero member, and its greatest common divisor with zero is itself. Working backward through the invariant proves that this last nonzero remainder is the answer for the original pair.
Read the computation as a certificate
The algorithm is useful even when factorization would be expensive. Successive remainder equations are easy to check using multiplication and subtraction, and the final nonzero remainder gives a compact certificate of the result. A single wrong quotient can corrupt every later line, so verify the range condition on every remainder. For a negative starting integer, division still works with a positive divisor and a nonnegative remainder; alternatively start with absolute values.
The word greatest refers to ordinary positive size, but the gcd also has a stronger property: every common divisor divides it. That property follows from the preserved divisor sets and the final pair. It lets the gcd organize later solvability tests for integer equations. A calculator displaying a decimal quotient has not answered this question; the important information is the integer remainder and the fact that the problem has become smaller.
Work it through
Two packing totals
Find the greatest common divisor of 252 and 198, displaying every nonzero remainder.
Divide 252 by 198: 252 = 1 × 198 + 54. Thus the original common divisors are exactly the common divisors of 198 and 54; 54 lies in the required remainder range.
Continue: 198 = 3 × 54 + 36, then 54 = 1 × 36 + 18. Each replacement preserves both directions of divisibility, rather than simply giving a plausible candidate.
Finish with 36 = 2 × 18 + 0. The last nonzero remainder is 18. Check independently that 252 = 14 × 18 and 198 = 11 × 18; the invariant rules out a larger common divisor.
The greatest common divisor is 18. Every common divisor of the two totals also divides 18.
The living notebook
Explore the model
Interactive lab · modular
A gcd controls an additive cycle
Pause and reset the lab, then set both controls: modulus m to 12 and additive step a to 8. Before playing, predict the orbit 0, 8, 4, 0 and its period three. Compute gcd(12, 8) = 4 by Euclid, then compare the displayed period 12/4. The instrument enumerates additive multiples modulo m; it does not animate the Euclidean remainder algorithm or factor the integers.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forThe same gcd that measures common divisibility determines how many distinct residues an additive stride reaches.
Pause & reason
Check your understanding
Your turn
Try it yourself
Compute gcd(391, 299). A student claims that this gcd divides every common divisor. Decide whether the claim is correct and state the useful divisibility direction.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Begin with 391 = 299 + 92, and distinguish “c divides d” from “d divides c.”
Compare with the solution
Continue 299 = 3 × 92 + 23 and 92 = 4 × 23. Therefore the gcd is 23. The useful conclusion is that every common divisor c divides 23, since the common-divisor sets are preserved. Claiming instead that 23 divides every common divisor is false: 1 is a common divisor, and 23 does not divide 1. This direction check distinguishes a greatest common divisor from a common multiple.
Keep the idea
Take it with you
- Divisibility requires an integer witness, not a rounded quotient.
- Remainder replacement preserves the complete set of common divisors.
- Strictly decreasing positive remainders prove that Euclid terminates.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.