The Euclidean algorithm for the GCD
4 min read
Short answer
Replace by until the remainder is ; the last non-zero remainder is . It works because , and it needs far fewer steps than factoring.
Why it is correct
If , any common divisor of and divides , and any common divisor of and divides . So the two pairs have the same common divisors, hence the same greatest one.
Bezout and inverses
Working the steps backwards writes for integers (extended Euclid). When the gcd is , is the inverse of mod , which is how modular division is done.
Worked example
Find and use it to simplify .
; ; . So . Dividing top and bottom by : .
Try it yourself
Compute .
Show the answer
; ; . The gcd is .
Keep going with practice
Vidi's linear algebra lessons use the same repeated-reduction idea in Gaussian elimination.