Sub topic 9
GCD and LCM from Prime Factorizations
Assume you can factor integers into primes and use exponent notation such as \(2^3\). You should also know that a factor divides a number evenly.
Greatest common divisor
The greatest common divisor (GCD) of two or more integers is the largest positive integer that divides every number.
For example, the common divisors of 84 and 90 include 1, 2, 3, and 6. Therefore,
\[ \gcd(84,90)=6. \]
Prime factorization makes the GCD systematic:
\[ 84=2^2\cdot3\cdot7 \]
\[ 90=2\cdot3^2\cdot5 \]
For each prime appearing in both factorizations, use the smaller exponent:
\[ \gcd(84,90)=2^1\cdot3^1=6. \]
A prime that appears in only one factorization does not belong in the GCD.
Least common multiple
The least common multiple (LCM) is the smallest positive integer that is a multiple of every given integer.
For the same numbers, the LCM uses every prime appearing in either factorization. For each prime, use the larger exponent:
\[ \operatorname{lcm}(84,90) =2^2\cdot3^2\cdot5\cdot7 =1260. \]
The GCD uses shared prime factors with minimum exponents. The LCM uses all prime factors with maximum exponents.
| Quantity | Rule for each prime | Result for 84 and 90 |
|---|---|---|
| GCD | Use the minimum exponent | \(2\cdot3=6\) |
| LCM | Use the maximum exponent | \(2^2\cdot3^2\cdot5\cdot7=1260\) |
A useful product relationship
For two positive integers \(a\) and \(b\),
\[ \gcd(a,b)\cdot\operatorname{lcm}(a,b)=a\cdot b. \]
Thus, if you know the GCD, you can find the LCM without rebuilding the factorization:
\[ \operatorname{lcm}(a,b)=\frac{ab}{\gcd(a,b)}. \]
For 84 and 90,
\[ \operatorname{lcm}(84,90)=\frac{84\cdot90}{6}=1260. \]
This relationship applies directly to two integers, not generally to three or more integers in one product equation.
from math import gcd
a, b = 84, 90
g = gcd(a, b)
l = a * b // g
print(g) # 6
print(l) # 1260
print(g * l == a * b) # TrueCommon errors and GRE strategy
- Do not use the larger exponent for the GCD.
- Do not discard a prime that appears in only one number when finding the LCM.
- Use positive values when the numbers may be negative. Divisors and multiples in these formulas are conventionally positive.
- For a quantitative comparison, factor only as much as needed. If one quantity asks for a GCD, focus on shared primes and minimum exponents.
- If the GCD and the product are given for two numbers, use the product relationship to find the LCM quickly.
Exercise
If \(x=2^3\cdot3^2\cdot5\) and \(y=2\cdot3^4\cdot7\), find \(\gcd(x,y)\) and \(\operatorname{lcm}(x,y)\).
Show answer
The GCD uses shared primes with minimum exponents: \(2^1\cdot3^2=18\). The LCM uses all primes with maximum exponents: \(2^3\cdot3^4\cdot5\cdot7=22{,}680\).