GCD
Example: GCD(15, 20) = ?
Positive divisors of 15:
Positive divisors of 20:
Common divisors:
GCD(15,20):
Manually writing out the divisors and finding the common divisors is quite slow.
Euclid’s Algorithm
- Put
- where
- Check value
- If then
- Otherwise ; put and and loop
To me: Remember to fix this algorithm description to be generic to i
Example: GCD(2024, 70) = ?
()
()
(, )
(, )
(, )
Algorithm terminates since .
Proof of Correctness
Firstly, is strictly decreasing so the process eventually terminates.
Extended Euclidean Algorithm
Run Euclid’s Algorithm backwards, and we get as a linear combination of . This is called the Extended Euclidean Algorithm.
2024 = 28x70 + 64
70 = 64 + 6
64 = 10x6 + 4
6 = 1x4 + 2
4 = 2x2 + 0
2 = 6 - 4
2 = 6 - (64 - 10x6) = 11x6 - 64
2 = 11(70-64) - 64 = 11x70 - 12x64
2 = 11x70 - 12(2024 - 28x70)
2 = 347x70 - 12x2024
Bezout’s Lemma
(Useful for solving diophantine eqs)
Proof is by induction
Corollary
If and then . This is because we can write as , and .
Euclid’s Lemma
Let , and let be a prime divisor of . Then or .