Skip to content
Number Theory · Chapter 19

GCD and LCM

Find the biggest shared divisor and the smallest shared multiple by sorting prime factors, and speed up the GCD with Euclid's square-cutting trick.

You'll need
open on YouTube
19.10%

GCD and LCM Fundamentals

In this section you will be able to find the GCD and the LCM of two numbers from their prime factorizations.

You have 12 red beads and 18 blue beads. You want identical bracelets that use every bead. What is the most bracelets you can make? That number is the GCD.

Break each number into prime tokens. The tokens both numbers share sit in the overlap of the Venn diagram.

The GCD uses only the shared tokens. The LCM uses every token, but a shared token only once.

Exploreplay first, formulas later

12 = 2^2 × 3, 18 = 2 × 3^2: GCD = 6, LCM = 36

12182233
Shared primes sit in the middle. Press a button to build the GCD or the LCM.
Product of shared tokens: 6. Product of all tokens: 36.

12 has 3 prime tokens, 18 has 3; 2 are shared

Name it

Definition 19.1.1 · Greatest Common Divisor

The Greatest Common Divisor (GCD) of two or more integers (which are not all zero) is the largest positive integer that divides each of the integers.

Note: This is also known as GCF (Greatest Common Factor), and the terms GCF and GCD are often used interchangeably.

Definition 19.1.2 · Least Common Multiple

The Least Common Multiple (LCM) of two or more integers (which are not all zero) is the smallest positive integer that is divisible by both the numbers.

Concept 19.1.3

Greatest common divisor of mm and nn =gcd⁡(m,n)= \gcd(m, n) can be found by taking the lowest prime exponents from the prime factorizations of mm and nn.

Least common multiple of mm and nn =lcm⁡(m,n)= \operatorname{lcm}(m, n) can be found by taking the highest prime exponents from the prime factorizations of mm and nn.

Watch itpredict, then reveal

Example 19.1

AMC 8

What is the ratio of the least common multiple of 180 and 594 to the greatest common factor of 180 and 594?

180 = 2^2 × 3^2 × 5, 594 = 2 × 3^3 × 11: GCD = 18, LCM = 5,940

18059425233311
Shared primes sit in the middle. Press a button to build the GCD or the LCM.
Product of shared tokens: 18. Product of all tokens: 5940.

180 has 5 prime tokens, 594 has 5; 3 are shared

  1. 1

    Break 180 into primes. How many factors of 2 does it have?

    Predict first:
open on YouTube

Contest cornerreal contest problems

Problem 19.5.2

AMC 8

The least common multiple of aa and bb is 12, and the least common multiple of bb and cc is 15. What is the least possible value of the least common multiple of aa and cc?

Problem 19.5.3

AIME

For how many values of kk is 121212^{12} the least common multiple of the positive integers 666^6, 888^8, and kk?

Checkpoint for section 19.1

Get 2 of 3 right to master this section. One try each, no hints.
1

What is gcd⁡(24,36)\gcd(24, 36)?

2

What is lcm⁡(8,12)\operatorname{lcm}(8, 12)?

3

Let a=23⋅52a = 2^3 \cdot 5^2 and b=2⋅54⋅7b = 2 \cdot 5^4 \cdot 7. What is lcm⁡(a,b)\operatorname{lcm}(a, b)?

19.20%

GCD and LCM Product

In this section you will be able to use GCD × LCM = m × n to find one of the four numbers from the other three.

Two mystery numbers multiply to 1260. Their LCM is 210. You can find their GCD without ever learning the numbers!

Multiply the two numbers and every prime token gets counted. The shared tokens get counted twice: once from each number.

The GCD holds the shared tokens once, and the LCM holds every token once. Together they hold the same tokens as m×nm \times n.

Exploreplay first, formulas later

12 = 2^2 × 3, 18 = 2 × 3^2: GCD = 6, LCM = 36

12182233shared tokens count twice in 12 × 18
6 × 36 = 216 = 12 × 18
gcd⁡(m,n)×lcm⁡(m,n)=m×n\gcd(m,n) \times \operatorname{lcm}(m,n) = m \times n
Product of shared tokens: 6. Product of all tokens: 36.

GCD × LCM = 6 × 36 = 216 = 12 × 18

Name it

Theorem 19.2.1

The product of GCD and LCM of two numbers is equal to the product of the two numbers:

gcd⁡(m,n)×lcm⁡(m,n)=m×n\gcd(m, n) \times \operatorname{lcm}(m, n) = m \times n

Watch itpredict, then reveal

Example 19.2

Suppose we have 2 numbers mm and nn such that mn=1260mn = 1260 and LCM⁡(m,n)=210\operatorname{LCM}(m, n) = 210. Find GCD⁡(m,n)\operatorname{GCD}(m, n).

  1. 1

    You know the product and the LCM. Which identity links them to the GCD?

    Predict first:

Try it

Problem 19.5.5(additional)

Omega Learn

If the GCD of 2 numbers is 12 and the LCM of the same 2 numbers is 240, find the product of the numbers.

Checkpoint for section 19.2

Get 2 of 3 right to master this section. One try each, no hints.
1

If the GCD of 2 numbers is 12 and the LCM of the same 2 numbers is 240, find the product of the numbers.

2

Two numbers multiply to 600 and their GCD is 5. What is their LCM?

3

gcd⁡(12,n)=4\gcd(12, n) = 4 and lcm⁡(12,n)=48\operatorname{lcm}(12, n) = 48. What is nn?

19.30%

More GCD/LCM Properties

In this section you will be able to scale out a common factor, and use the fact that every common multiple is a multiple of the LCM.

A red light blinks every 4 seconds and a blue light every 6 seconds. They just blinked together. When do they blink together again? And after that?

The common marks are 12, 24, 36 and so on. Look: they are exactly the multiples of the LCM.

Multiplying both numbers by the same cc just multiplies the GCD and the LCM by cc too.

The last two examples turn GCD and LCM facts into facts about prime exponents. Go one prime at a time!

Exploreplay first, formulas later

Multiples of 4, 6 up to 40: common marks 12, 24, 36; LCM = 12

line 14
line 26
up to40
×4481216202428323640×661218243036
Where do the lines first meet?

Multiples of 4 and 6 up to 40.

Name it

Theorem 19.3.1

gcd⁡(ac,bc)=c⋅gcd⁡(a,b)\gcd(ac, bc) = c \cdot \gcd(a, b)

Theorem 19.3.2

lcm⁡(ac,bc)=c⋅lcm⁡(a,b)\operatorname{lcm}(ac, bc) = c \cdot \operatorname{lcm}(a, b)

Theorem 19.3.3

If a number is divisible by two numbers aa and bb, it will also be divisible by lcm⁡(a,b)\operatorname{lcm}(a, b).

Watch itpredict, then reveal

Example 19.3

Omega Learn

Let aa be the smallest positive perfect cube that's divisible by 15, 22, and 176. If a=b3a = b^3, find bb.

  1. 1

    A number divisible by 15, 22 and 176 must be divisible by one single number. Which one?

    Predict first:
open on YouTube

Example 19.5

Omega Learn

3 numbers aa, bb, and cc satisfy the conditions that gcd⁡(a,b)=4\gcd(a, b) = 4, gcd⁡(b,c)=18\gcd(b, c) = 18, and lcm⁡(a,c)=144\operatorname{lcm}(a, c) = 144. Find the value of a+ca + c.

Multiples of 4, 18 up to 120: common marks 36, 72, 108; LCM = 36

up to120
×481624324048566472808896104112120×183672108
Where do the lines first meet?

Multiples of 4 and 18 up to 120.

  1. 1

    What must be true about aa and bb if gcd⁡(a,b)=4\gcd(a, b) = 4?

Example 19.6

AMC 12

How many positive integers nn are there such that nn is a multiple of 5, and the least common multiple of 5!5! and nn equals 5 times the greatest common divisor of 10!10! and nn?

  1. 1

    Write 5!5! and 10!10! as prime factorizations. What is the exponent of 2 in 10!10!?

    Predict first:
open on YouTube

Try it

Problem 19.5.6(additional)

Omega Learn

Two numbers aa and bb satisfy the condition lcm⁡(gcd⁡(24,a),gcd⁡(a,b))=lcm⁡(gcd⁡(24,b),gcd⁡(a,b))\operatorname{lcm}(\gcd(24, a), \gcd(a, b)) = \operatorname{lcm}(\gcd(24, b), \gcd(a, b)). If a=2ba = 2b, what is the smallest possible value of a+ba + b?

Contest cornerreal contest problems

Problem 19.5.1

AMC 10

Each piece of candy in a store costs a whole number of cents. Casper has exactly enough money to buy either 12 pieces of red candy, 14 pieces of green candy, 15 pieces of blue candy, or nn pieces of purple candy. A piece of purple candy costs 20 cents. What is the smallest possible value of nn?

Problem 19.5.4

AMC 10

Let a,b,c,a, b, c, and dd be positive integers such that gcd⁡(a,b)=24\gcd(a, b) = 24, gcd⁡(b,c)=36\gcd(b, c) = 36, gcd⁡(c,d)=54\gcd(c, d) = 54, and 70<gcd⁡(d,a)<10070 < \gcd(d, a) < 100. Which of the following must be a divisor of aa?

(Choices from the original contest: 5, 7, 11, 13, 17.)

Problem 19.5.8(additional)

Omega Learn

Three numbers aa, bb, and cc satisfy the conditions that gcd⁡(a,b)=20\gcd(a, b) = 20, gcd⁡(b,c)=18\gcd(b, c) = 18, and lcm⁡(a,c)=5040\operatorname{lcm}(a, c) = 5040. Find the sum of all possible values of a+ca + c.

Checkpoint for section 19.3

Get 2 of 3 right to master this section. One try each, no hints.
1

Use gcd⁡(ac,bc)=c⋅gcd⁡(a,b)\gcd(ac, bc) = c \cdot \gcd(a, b) to find gcd⁡(700,1100)\gcd(700, 1100).

2

Use lcm⁡(ac,bc)=c⋅lcm⁡(a,b)\operatorname{lcm}(ac, bc) = c \cdot \operatorname{lcm}(a, b) to find lcm⁡(30,45)\operatorname{lcm}(30, 45).

3

A number is divisible by 6 and by 10. What is the largest number it must also be divisible by?

19.40%

Euclidean Algorithm

In this section you will be able to find the GCD of big numbers fast by subtracting the smaller number from the bigger one.

Factoring 186 and 92 is slow. Here is a faster trick: keep cutting the biggest squares you can out of a 186 × 92 rectangle.

Any number that divides both xx and yy also divides x−yx - y. So taking yy away from xx never changes the GCD.

Keep subtracting until one number hits 0. The other number is the GCD.

Exploreplay first, formulas later

30 × 12 rectangle, 0 of 2 cuts: gcd(30, 12); GCD = 6

gcd(30, 12)

Squares cut so far: 0. Left over: a 30 × 12 rectangle.

gcd(30, 12)

Name it

Theorem 19.4.1 · Euclidean Algorithm

The Euclidean algorithm states that

gcd⁡(x,y)=gcd⁡(x−ky,y)\gcd(x, y) = \gcd(x - ky, y)

where x>yx > y and kk is a positive integer.

Watch itpredict, then reveal

Example 19.4

Find the GCD of 186 and 92.

186 × 92 rectangle, 0 of 2 cuts: gcd(186, 92); GCD = 2

gcd(186, 92)

Squares cut so far: 0. Left over: a 186 × 92 rectangle.

gcd(186, 92)

  1. 1

    Take as many 92s away from 186 as you can. What is left?

    Predict first:

Contest cornerreal contest problems

Problem 19.5.9(additional)

AMC 10

Let nn be the least positive integer greater than 1000 for which

gcd⁡(63,n+120)=21andgcd⁡(n+63,120)=60.\gcd(63, n + 120) = 21 \quad\text{and}\quad \gcd(n + 63, 120) = 60.

What is the sum of the digits of nn?

Checkpoint for section 19.4

Get 2 of 3 right to master this section. One try each, no hints.
1

Use the Euclidean algorithm to find gcd⁡(91,35)\gcd(91, 35).

2

Find gcd⁡(323,391)\gcd(323, 391).

3

A 48×1848 \times 18 rectangle is cut into the largest squares possible, again and again, until nothing is left. What is the side of the smallest square?

19.5

Practice Problems

In this section you will be able to put GCD and LCM exponent counting to work on a tough contest problem.

Time for an AIME problem! Split it into the powers of 2 and the powers of 5, count each, and multiply. Every problem has three hints if you get stuck.

Want every problem from this chapter on one page? Open the problem set.

Contest cornerreal contest problems

Problem 19.5.7(additional)

AIME

Let [r,s][r, s] denote the least common multiple of positive integers rr and ss. Find the number of ordered triples (a,b,c)(a, b, c) of positive integers for which [a,b]=1000[a, b] = 1000, [b,c]=2000[b, c] = 2000, and [c,a]=2000[c, a] = 2000.