AMC 10 Step by Step
Printable problems

GCD & LCM

GCD/LCM computation, Euclidean algorithm, gcd*lcm = product

What you need to know

  • gcd times lcm. The gcd (greatest common divisor) is the biggest number dividing both aa and bb; the lcm (least common multiple) is the smallest positive number both divide. For positive integers, gcd⁡(a,b)⋅lcm(a,b)=a⋅b\gcd(a,b)\cdot\text{lcm}(a,b) = a\cdot b.
  • With prime factorizations, the gcd takes the smaller exponent of each prime and the lcm takes the larger. Example: 24=23⋅324 = 2^3\cdot3 and 90=2⋅32⋅590 = 2\cdot3^2\cdot5 have gcd 2⋅3=62\cdot3 = 6 and lcm 23⋅32⋅5=3602^3\cdot3^2\cdot5 = 360, and 6⋅360=24⋅90=21606\cdot360 = 24\cdot90 = 2160.
  • Euclidean Algorithm. gcd⁡(a,b)=gcd⁡(b,r)\gcd(a,b) = \gcd(b,r), where rr is the remainder when aa is divided by bb. Repeat until the remainder is 00. Example: gcd⁡(252,105)=gcd⁡(105,42)=gcd⁡(42,21)=gcd⁡(21,0)=21\gcd(252,105) = \gcd(105,42) = \gcd(42,21) = \gcd(21,0) = 21.
  • Subtracting multiples. More generally, gcd⁡(a,b)=gcd⁡(a,b−ka)\gcd(a,b) = \gcd(a,b-ka) for any integer kk, because a number that divides aa and bb also divides b−kab-ka, and the other way round. Example: gcd⁡(35,91)=gcd⁡(35,91−2⋅35)=gcd⁡(35,21)=7\gcd(35,91) = \gcd(35,91-2\cdot35) = \gcd(35,21) = 7.
  • Pulling out the gcd. If gcd⁡(a,b)=g\gcd(a,b) = g, write a=gxa = gx and b=gyb = gy. Then xx and yy share no factor except 11, and lcm(a,b)=gxy\text{lcm}(a,b) = gxy. Example: 24=6⋅424 = 6\cdot4 and 90=6⋅1590 = 6\cdot15, so the lcm is 6⋅4⋅15=3606\cdot4\cdot15 = 360.
  • Relatively prime (or coprime) means the gcd is 11. Consecutive integers are always relatively prime, since a common divisor would also divide their difference, 11.
  • Things that repeat. lcm(a1,…,ak)\text{lcm}(a_1, \dots, a_k) is the smallest positive number that all of a1,…,aka_1, \dots, a_k divide. So things that repeat every a1a_1, …, aka_k days all line up again every lcm days. Example: buses every 44, 66, and 1010 minutes leave together every lcm(4,6,10)=60\text{lcm}(4,6,10) = 60 minutes.
  • Counting numbers relatively prime to mm. For the numbers from 11 to NN, use the Principle of Inclusion-Exclusion (PIE) on the primes of mm. Example: from 11 to 30=2⋅3⋅530 = 2\cdot3\cdot5: 30−(15+10+6)+(5+3+2)−1=830-(15+10+6)+(5+3+2)-1 = 8.

How AMC 10 tests it

  • Word problems in disguise: events with periods of 33, 44, 66, 77 days line up every lcm days; tiles or fence posts use the gcd.
  • "Given gcd⁡(a,b)\gcd(a,b) and lcm(a,b)\text{lcm}(a,b), how many pairs (a,b)(a,b)?" or "what is a+ba+b?" (usually problems 12–18).
  • The gcd of huge numbers or expressions, such as gcd⁡(230−1,218−1)\gcd(2^{30}-1, 2^{18}-1) or gcd⁡(n2+1,n+1)\gcd(n^2+1, n+1), meant to be simplified with the Euclidean Algorithm.
  • Fractions in lowest terms: ab\frac{a}{b} reduces to denominator bgcd⁡(a,b)\frac{b}{\gcd(a,b)}; count the numerators that give a certain reduced denominator.

Standard approaches

  1. Factor both numbers and take the smaller or larger exponent of each prime. This settles any gcd or lcm of actual numbers.
  2. For expressions or huge numbers, subtract multiples. Example: n2+1=(n+1)(n−1)+2n^2+1 = (n+1)(n-1)+2, so gcd⁡(n2+1,n+1)=gcd⁡(2,n+1)\gcd(n^2+1, n+1) = \gcd(2, n+1): 22 if nn is odd, 11 if nn is even. Likewise 230−1−212(218−1)=212−12^{30}-1-2^{12}(2^{18}-1) = 2^{12}-1, and continuing gives gcd⁡(230−1,218−1)=26−1=63\gcd(2^{30}-1, 2^{18}-1) = 2^6-1 = 63.
  3. Write a=gxa = gx and b=gyb = gy with gcd⁡(x,y)=1\gcd(x,y) = 1; the problem becomes counting relatively prime pairs.
  4. Use ab=gcd⁡⋅lcmab = \gcd\cdot\text{lcm} whenever three of the four are known. Example: if gcd⁡(a,12)=4\gcd(a,12) = 4 and lcm(a,12)=48\text{lcm}(a,12) = 48, then a=4⋅4812=16a = \frac{4\cdot48}{12} = 16.
  5. For ordered pairs of relatively prime numbers with product mm, each prime power of mm goes entirely to one side. If mm has kk different prime factors, that gives 2k2^k pairs. Example: 12=22⋅312 = 2^2\cdot3 gives 22=42^2 = 4 pairs: (1,12)(1,12), (4,3)(4,3), (3,4)(3,4), (12,1)(12,1).

Worked example

How many ordered pairs of positive integers (a,b)(a, b) satisfy gcd⁡(a,b)=6\gcd(a, b) = 6 and lcm⁡(a,b)=360\operatorname{lcm}(a, b) = 360?

(A) 44 (B) 66 (C) 88 (D) 1212 (E) 1616

Step 1: pull out the gcd. Write a=6xa = 6x and b=6yb = 6y. Then xx and yy share no factor except 11; otherwise the gcd would be bigger than 66.

Step 2: use the lcm. lcm(a,b)=6xy=360\text{lcm}(a,b) = 6xy = 360, so xy=60=22⋅3⋅5xy = 60 = 2^2\cdot3\cdot5.

Step 3: split the primes. Since xx and yy share no factor, each of 22=42^2 = 4, 33, and 55 goes entirely to xx or entirely to yy. (If each got one 22, both would be even.) That is 23=82^3 = 8 choices: (x,y)=(1,60)(x,y) = (1,60), (4,15)(4,15), (3,20)(3,20), (5,12)(5,12), and these four reversed.

Step 4: check one. (4,15)(4,15) gives (a,b)=(24,90)(a,b) = (24,90), with gcd 66 and lcm 360360.

The answer is (C) 8\boxed{\textbf{(C)}\ 8}.

Pitfalls

  • Using "gcd ×\times lcm == product" for three or more numbers; it holds only for two. Example: for 22, 44, 88, gcd ×\times lcm =2⋅8=16= 2\cdot8 = 16, but the product is 6464.
  • Forgetting that xx and yy must share no factor after you pull out gg, which overcounts. Example: above, (x,y)=(2,30)(x,y) = (2,30) gives (a,b)=(12,180)(a,b) = (12,180), whose gcd is 1212, not 66.
  • Mixing up ordered and unordered pairs; (a,b)(a,b) and (b,a)(b,a) count separately unless the problem says otherwise.
  • Subtracting the wrong way in the Euclidean Algorithm, such as replacing aa with a−ba-b when bb is bigger, and losing track of minus signs. Subtract the smaller from the larger.

Traps that recur

  • Accepting statement I by analogy with II without testing it; a = 1, b = 3 gives c = 57, which is divisible by 3. (2023 AMC 10B #18)
  • Stopping at the first n > 1000 satisfying the divisibility parts (n = 1077, digit sum 15) without checking that the gcds are exactly 21 and 60. (2020 AMC 10A #24)
  • Assuming gcd(d,a) is just some multiple of 6 and picking 72, 84, 90 or 96, which would force extra factors of 2 or 3 that contradict the given gcds. (2018 AMC 10A #22)
  • Forgetting that x and y must be coprime, so that xy = 9 wrongly admits (3,3) (which has gcd 63, not 21) and yields 3 ordered pairs instead of 2. (2018 AMC 10B #23)

Problems © Mathematical Association of America (MAA), American Mathematics Competitions. Reproduced for non-commercial educational use. The topic note, tags and key insights are original to this site.