Factorisation gives a formula
Take the minimum exponent of each prime for the gcd, and the maximum for the lcm. Correct, and it requires factoring both numbers.
gcd(a,b) is the largest common divisor. Computing it from prime factorisations is correct and impractical; “The Euclidean Algorithm”'s algorithm is what makes it fast.
Core ideas
The definition is immediate; the interesting question is how to compute it without factoring.
Take the minimum exponent of each prime for the gcd, and the maximum for the lcm. Correct, and it requires factoring both numbers.
gcd · lcm = |ab|, because min and max exponents together account for both exponents at each prime.
gcd(a,b) = 1. Consecutive integers are always coprime, which is the fact the Chinese remainder theorem uses in “The Chinese Remainder Theorem”.
The material
The definitions, the factorisation formulas, and why they are not the method.
For integers a, b not both zero, gcd(a,b) is the largest positive integer dividing both. gcd(a, 0) = |a|.
For nonzero a, b, lcm(a,b) is the smallest positive integer divisible by both.
If a = Π p^{aᵢ} and b = Π p^{bᵢ} over the same set of primes (with zero exponents allowed), then gcd(a,b) = Π p^{min(aᵢ,bᵢ)} and lcm(a,b) = Π p^{max(aᵢ,bᵢ)}.
A common divisor may use each prime at most as often as the smaller exponent allows, and taking exactly that many gives the largest such divisor. The lcm argument is the mirror image with maxima.
□
gcd(a,b) · lcm(a,b) = |a · b|.
At each prime, min(aᵢ,bᵢ) + max(aᵢ,bᵢ) = aᵢ + bᵢ. Multiplying over all primes gives the identity.
□
The identity is the practical way to get an lcm: compute the gcd by Euclid's algorithm and divide. Finding the lcm directly would require the factorisations.
48 = 2⁴·3 and 180 = 2²·3²·5. gcd = 2^{min(4,2)}·3^{min(1,2)}·5^{min(0,1)} = 4·3 = 12. lcm = 2⁴·3²·5 = 720. Check: 12 · 720 = 8640 = 48 · 180.
The formula requires factoring both numbers, and factoring is hard. For two 100-digit numbers no known method factors them in reasonable time, yet Euclid's algorithm computes their gcd in a few hundred divisions.
This gap is worth noticing. Computing the gcd is easy and factoring is hard, even though the formula above expresses the gcd in terms of the factorisations. An easy problem can have a hard-looking definition, and “The Euclidean Algorithm” is the reason this one is easy.
a and b are coprime (relatively prime) when gcd(a,b) = 1: they share no prime factor. Neither number need be prime — 8 and 9 are coprime and both are composite; coprimality is a property of the pair. A set is pairwise coprime when every two of its members are.
gcd(n, n+1) = 1 for every n.
Any common divisor d divides the difference (n+1) − n = 1, so d = 1. This is the linear-combination property of “Divisibility and the Division Algorithm”.
□
Interactive
Algorithms with their traces
Method
Euclid for the gcd; the identity for the lcm.
Never factorisation, unless the numbers are tiny or the factorisations are already known.
lcm(a,b) = |ab| / gcd(a,b). Divide before multiplying to keep the numbers small.
gcd(a,b,c) = gcd(gcd(a,b), c), and similarly for lcm. Note the product identity does NOT extend to three numbers.
The gcd divides both inputs; both inputs divide the lcm. Two free checks.
Two routes, and a warning about the second.
For three numbers the product identity fails: gcd(2,4,8) = 2 and lcm(2,4,8) = 8, while the product is 64. The gcd and lcm still extend by associativity; only the identity relating them does not.
Compute gcd(1071, 462) and lcm(1071, 462) without factoring either number. The gcd takes three divisions and the lcm follows from the identity.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.