How to Find the GCD and LCM: Methods, Examples and Table

Prime factorization, the Euclidean algorithm and solved word problems to find the greatest common divisor and least common multiple, with a table of common pairs.

The greatest common divisor (GCD) and the least common multiple (LCM) come up as soon as you simplify a fraction, add fractions with different denominators or solve a “when do they meet again?” problem. The GCD is also called the greatest common factor (GCF) or the highest common factor (HCF). This guide covers the two most used methods, step-by-step examples, a table of the pairs that appear most often in homework, and the mistakes teachers see again and again.

Find the GCD and LCM instantly

Type two or more whole numbers separated by commas: the calculator shows the GCD, the LCM and the prime factorization of each number.

Open the GCD and LCM calculator →

What are the GCD and the LCM?

  • The GCD of several numbers is the largest number that divides all of them with no remainder. The GCD of 12 and 18 is 6.
  • The LCM is the smallest number (other than zero) that is a multiple of all of them. The LCM of 12 and 18 is 36.

A quick way not to mix them up: the GCD is never larger than the smallest number, and the LCM is never smaller than the largest number.

Method 1: prime factorization

Break each number down into prime factors, then:

  • GCD = product of the common factors, each with its lowest exponent.
  • LCM = product of all the factors, common or not, each with its highest exponent.

Example 1: GCD and LCM of 12, 18 and 30

  • 12 = 22 · 3
  • 18 = 2 · 32
  • 30 = 2 · 3 · 5
  • Factors common to all three: 2 and 3, lowest exponent 1 → GCD = 2 · 3 = 6
  • All factors with their highest exponent: 22, 32 and 5 → LCM = 4 · 9 · 5 = 180

Method 2: the Euclidean algorithm (for the GCD)

With large numbers, factorizing is slow. The Euclidean algorithm divides the larger number by the smaller one, replaces the pair with (divisor, remainder) and repeats until the remainder is 0. The last divisor is the GCD.

Example 2: GCD and LCM of 84 and 120

  • 120 = 1 × 84 + 36
  • 84 = 2 × 36 + 12
  • 36 = 3 × 12 + 0 → GCD = 12

For two numbers, the LCM follows from the relation GCD × LCM = a × b: LCM = 84 × 120 ÷ 12 = 840. Careful: this relation only works for two numbers, not for three or more.

You can follow each division with the Euclidean algorithm calculator.

Typical word problems

When do they meet again? One bus comes every 12 minutes and another every 18 minutes. If they leave together at 8:00, they meet again after LCM(12, 18) = 36 minutes, at 8:36. You use the LCM because you are looking for a common multiple.

Equal pieces, as long as possible. Two boards of 84 in and 120 in must be cut into equal pieces, with no waste and as long as possible. The length is GCD(84, 120) = 12 in: 7 pieces from the first board and 10 from the second. You use the GCD because you are looking for a common divisor.

Adding fractions. To work out 5/12 + 7/18, use LCM(12, 18) = 36 as the common denominator: 15/36 + 14/36 = 29/36.

GCD and LCM table for common pairs

Results calculated with the same method as the GCD and LCM calculator. The last column checks the relation GCD × LCM = a × b.

NumbersPrime factorizationGCDLCMGCD × LCM
8 and 128 = 23; 12 = 22 · 342496 = 8 × 12
12 and 1812 = 22 · 3; 18 = 2 · 32636216 = 12 × 18
14 and 2114 = 2 · 7; 21 = 3 · 7742294 = 14 × 21
15 and 2015 = 3 · 5; 20 = 22 · 5560300 = 15 × 20
16 and 4016 = 24; 40 = 23 · 5880640 = 16 × 40
18 and 2418 = 2 · 32; 24 = 23 · 3672432 = 18 × 24
24 and 3624 = 23 · 3; 36 = 22 · 321272864 = 24 × 36
25 and 3525 = 52; 35 = 5 · 75175875 = 25 × 35
36 and 4836 = 22 · 32; 48 = 24 · 3121441,728 = 36 × 48
45 and 6045 = 32 · 5; 60 = 22 · 3 · 5151802,700 = 45 × 60
60 and 9060 = 22 · 3 · 5; 90 = 2 · 32 · 5301805,400 = 60 × 90
75 and 10075 = 3 · 52; 100 = 22 · 52253007,500 = 75 × 100
7 and 97 = 7; 9 = 3216363 = 7 × 9
84 and 12084 = 22 · 3 · 7; 120 = 23 · 3 · 51284010,080 = 84 × 120

When the GCD is 1, as with 7 and 9, the numbers are coprime (relatively prime) and their LCM is simply their product.

Common mistakes

  • Swapping the rules. For the GCD, take only the common factors with the lowest exponent; for the LCM, take every factor with the highest exponent.
  • Forgetting a non-common factor in the LCM. In example 1, leaving out the 5 gives 36 instead of 180.
  • Using GCD × LCM = a × b with three numbers. With 12, 18 and 30 the product is 6,480, but GCD × LCM = 6 × 180 = 1,080.
  • Picking the wrong one in a word problem. “Meet again” or “at the same time” calls for the LCM; “split into equal parts as large as possible” calls for the GCD.

FAQ

What is the GCD of two different prime numbers? Always 1, and their LCM is their product: GCD(7, 11) = 1 and LCM(7, 11) = 77.

Can the LCM be one of the numbers? Yes, when one is a multiple of the other: LCM(8, 24) = 24 and GCD(8, 24) = 8.

Can I work with more than two numbers? Yes. Factorize all of them at once, or go step by step: GCD(12, 18, 30) = GCD(GCD(12, 18), 30) = GCD(6, 30) = 6.

Are GCF, HCF and GCD the same thing? Yes. They are three names for the same number; GCF is common in US schools and HCF in the UK.

Related calculators

AllCalculs Team
AllCalculs Team

The AllCalculs team builds free online calculators and writes these guides. Every formula and example is checked against the calculator it links to.

Articles: 96