dash–calculator

04 Numbers and Counting

GCD and LCM Table for Numbers 1 to 20

Readout 04-0512 · Updated · Standard formula, shown below

LCM = a·b / GCD 72
First number a
18
Input
Second number b
24
Input
Their GCD (from the table)
6
Input
You enter
First number a, Second number b, Their GCD (from the table)
You get
LCM = a·b / GCD
Rounding
0 dp

This page provides a quick reference for the greatest common divisor (GCD, also called GCF or HCF) and the least common multiple (LCM) for small numbers. The GCD table covers all pairs from 1 to 20, while the LCM table covers pairs from 1 to 12. A third table lists the LCM of all integers from 1 up to n, for n from 1 to 20.

These tables are useful for students learning fraction arithmetic, for teachers preparing examples, and for anyone who needs to simplify fractions or find a common denominator without performing a full calculation. The patterns in the tables also illustrate important properties of divisibility and prime numbers.

Formula

gcd(a, b) is the largest whole number dividing both; Euclid: gcd(a, b) = gcd(b, a mod b), ending when the remainder is 0. lcm(a, b) = a × b / gcd(a, b). From prime factorizations: gcd takes the lower power of each prime, lcm the higher power.

Worked Example

Find gcd(18, 24) and lcm(18, 24), the calculator defaults.

Step Working Result
1 gcd(18, 24): 24 = 1 × 18 + 6 remainder 6
2 18 = 3 × 6 + 0 gcd = 6
3 lcm = 18 × 24 / 6 72
4 check: 72 / 18 and 72 / 24 4 and 3

GCD grid for a, b = 1 to 20

a \ b 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
3 1 1 3 1 1 3 1 1 3 1 1 3 1 1 3 1 1 3 1 1
4 1 2 1 4 1 2 1 4 1 2 1 4 1 2 1 4 1 2 1 4
5 1 1 1 1 5 1 1 1 1 5 1 1 1 1 5 1 1 1 1 5
6 1 2 3 2 1 6 1 2 3 2 1 6 1 2 3 2 1 6 1 2
7 1 1 1 1 1 1 7 1 1 1 1 1 1 7 1 1 1 1 1 1
8 1 2 1 4 1 2 1 8 1 2 1 4 1 2 1 8 1 2 1 4
9 1 1 3 1 1 3 1 1 9 1 1 3 1 1 3 1 1 9 1 1
10 1 2 1 2 5 2 1 2 1 10 1 2 1 2 5 2 1 2 1 10
11 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1
12 1 2 3 4 1 6 1 4 3 2 1 12 1 2 3 4 1 6 1 4
13 1 1 1 1 1 1 1 1 1 1 1 1 13 1 1 1 1 1 1 1
14 1 2 1 2 1 2 7 2 1 2 1 2 1 14 1 2 1 2 1 2
15 1 1 3 1 5 3 1 1 3 5 1 3 1 1 15 1 1 3 1 5
16 1 2 1 4 1 2 1 8 1 2 1 4 1 2 1 16 1 2 1 4
17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 17 1 1 1
18 1 2 3 2 1 6 1 2 9 2 1 6 1 2 3 2 1 18 1 2
19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 1
20 1 2 1 4 5 2 1 4 1 10 1 4 1 2 5 4 1 2 1 20

How to read this table

Each table is symmetric: the value for row a and column b is the same as the value for row b and column a. For the GCD table, find the row for the first number and the column for the second number; the entry at their intersection is the largest integer that divides both numbers. For example, the row for 12 and the column for 18 gives 6, so gcd(12, 18) = 6.

For the LCM table, the entry is the smallest positive integer that is a multiple of both numbers. For instance, the row for 6 and the column for 10 gives 30, so lcm(6, 10) = 30. The row for 8 and the column for 12 gives 24, so lcm(8, 12) = 24.

The third table lists the LCM of all integers from 1 to n. For example, the entry for n = 6 is 60, meaning 60 is the smallest number divisible by 1, 2, 3, 4, 5, and 6.

LCM grid for a, b = 1 to 12

a \ b 1 2 3 4 5 6 7 8 9 10 11 12
1 1 2 3 4 5 6 7 8 9 10 11 12
2 2 2 6 4 10 6 14 8 18 10 22 12
3 3 6 3 12 15 6 21 24 9 30 33 12
4 4 4 12 4 20 12 28 8 36 20 44 12
5 5 10 15 20 5 30 35 40 45 10 55 60
6 6 6 6 12 30 6 42 24 18 30 66 12
7 7 14 21 28 35 42 7 56 63 70 77 84
8 8 8 24 8 40 24 56 8 72 40 88 24
9 9 18 9 36 45 18 63 72 9 90 99 36
10 10 10 30 20 10 30 70 40 90 10 110 60
11 11 22 33 44 55 66 77 88 99 110 11 132
12 12 12 12 12 60 12 84 24 36 60 132 12

LCM of all numbers 1 to n

n lcm(1 … n)
1 1
2 2
3 6
4 12
5 60
6 60
7 420
8 840
9 2,520
10 2,520
11 27,720
12 27,720
13 360,360
14 360,360
15 360,360
16 720,720
17 12,252,240
18 12,252,240
19 232,792,560
20 232,792,560

Patterns and Properties in the Tables

Several patterns are immediately visible in the GCD and LCM tables. In the GCD table, the main diagonal (where a = b) always equals the number itself, because any number divides itself. The first row and first column are all 1, since 1 divides every number. A pair of numbers has gcd 1 exactly when they share no prime factors; such pairs are called coprime. Similarly, 17 and 20 have gcd 1, as seen in the row for 17 and column for 20.

In the LCM table, the main diagonal equals the number itself, because the least common multiple of a number with itself is that number. The first row and first column equal the other number, since lcm(1, b) = b. When two numbers are coprime, their LCM is their product. For example, 5 and 7 are coprime, and the LCM table shows 35 at their intersection. When one number divides the other, the LCM is the larger number; for instance, lcm(4, 12) = 12.

The LCM of all numbers 1 to n grows quickly. It stays the same when n is not a prime power; for example, lcm(1..5) = 60 and lcm(1..6) = 60, because 6 does not introduce a new prime factor. But lcm(1..7) jumps to 420 because 7 is prime. The table shows that lcm(1..20) is 232,792,560, a number divisible by every integer from 1 to 20.

Computing GCD and LCM by Hand

There are two standard methods to find the GCD and LCM of two numbers: the prime-factor method and Euclid’s algorithm.

Prime-Factor Method

Write each number as a product of primes. The GCD takes the lower power of each prime that appears in both factorizations; if a prime appears in only one number, it is not included. The LCM takes the higher power of each prime that appears in either number. For example, 18 = 2 × 3² and 24 = 2³ × 3. The GCD uses 2¹ and 3¹, giving 6. The LCM uses 2³ and 3², giving 72. This matches the worked example.

Euclid’s Algorithm

Euclid’s algorithm is efficient for larger numbers. It uses the fact that gcd(a, b) = gcd(b, a mod b), where a mod b is the remainder when a is divided by b. Repeat until the remainder is 0; the last nonzero remainder is the GCD. For example, to find gcd(18, 24): 24 mod 18 = 6, then 18 mod 6 = 0, so the GCD is 6. Once the GCD is known, the LCM is a × b / gcd(a, b). For 18 and 24, that gives 18 × 24 / 6 = 72.

Practical Uses: Simplifying Fractions and Finding Common Denominators

The GCD and LCM are essential for working with fractions.

Reducing Fractions

To simplify a fraction, divide both the numerator and denominator by their GCD. For example, to reduce 18/24, compute gcd(18, 24) = 6, then divide both numbers by 6 to get 3/4. The GCD table quickly shows that gcd(18, 24) = 6, so you can reduce the fraction without further calculation.

Adding and Subtracting Fractions

To add or subtract fractions with different denominators, find the LCM of the denominators. This LCM becomes the least common denominator. For instance, to add 1/6 and 1/10, find lcm(6, 10) = 30. Convert each fraction to an equivalent fraction with denominator 30: 1/6 = 5/30 and 1/10 = 3/30, then add to get 8/30, which simplifies to 4/15. The LCM table provides these values directly for numbers up to 12.

Using the least common denominator keeps the numbers as small as possible, reducing the need for extra simplification later.

Common Mistakes and How to Avoid Them

When working with GCD and LCM, several errors are common.

  • Confusing GCD and LCM: The GCD is the largest divisor, while the LCM is the smallest multiple. For 18 and 24, the GCD is 6 and the LCM is 72. Remember that the GCD is always less than or equal to both numbers, while the LCM is always greater than or equal to both numbers.
  • Forgetting that the product equals GCD × LCM: The identity gcd(a, b) × lcm(a, b) = a × b holds for any two positive integers. Use this as a check.
  • Using the wrong power in the prime-factor method: For the GCD, take the lower exponent; for the LCM, take the higher exponent. For example, for 8 and 12, 8 = 2³ and 12 = 2² × 3. The GCD is 2² = 4, and the LCM is 2³ × 3 = 24.
  • For example, 5 and 7 are coprime, so lcm(5, 7) = 35. But for 6 and 10, the GCD is 2, so the LCM is 30, not 60.

Limits and Precision of the Tables

The GCD table covers numbers from 1 to 20, and the LCM table covers numbers from 1 to 12. For pairs beyond these ranges, you cannot use the tables directly, but the same formulas and algorithms apply. Euclid’s algorithm works for any positive integers, and the prime-factor method works as long as you can factor the numbers.

The table for the LCM of all numbers 1 to n extends to n = 20. The values grow quickly; for example, lcm(1..20) is 232,792,560. For n larger than 20, the LCM becomes even larger, and the table does not provide those values. However, you can compute them by taking the product of the highest power of each prime that is less than or equal to n.

All values in the tables are exact integers. There is no rounding or precision loss. When using the calculator on this page, the results are also exact for the ranges supported. For very large numbers, the calculator may have limits, but the mathematical methods described here remain valid.

Frequently Asked Questions

What is the difference between GCD and LCM?

The GCD (greatest common divisor) is the largest number that divides both given numbers. The LCM (least common multiple) is the smallest number that is a multiple of both. For example, for 18 and 24, the GCD is 6 and the LCM is 72. The GCD is always less than or equal to the smaller number, while the LCM is always greater than or equal to the larger number.

How do I use the GCD table to reduce a fraction?

Find the row for the numerator and the column for the denominator (or vice versa) in the GCD table. The entry is the GCD. Divide both the numerator and denominator by that number. For example, to reduce 18/24, find gcd(18, 24) = 6, then divide both by 6 to get 3/4.

How do I find the LCM of two numbers using the tables?

Look up the pair in the LCM table (for numbers 1 to 12). The entry at the intersection of the row and column is the LCM. For numbers larger than 12, use the formula lcm(a, b) = a × b / gcd(a, b). First find the GCD using Euclid's algorithm, then compute the product divided by that GCD.

What does it mean for two numbers to be coprime?

Two numbers are coprime if their greatest common divisor is 1. This means they share no prime factors. For example, 7 and 20 are coprime because gcd(7, 20) = 1. When two numbers are coprime, their LCM is simply their product, such as lcm(5, 7) = 35.

Why does the LCM of 1 to n sometimes stay the same?

For example, lcm(1..5) = 60 and lcm(1..6) = 60 because 6 = 2 × 3 does not add any new prime factors. But lcm(1..7) = 420 because 7 is a new prime.

Calculators that go with this table

Method and sources

Exact integer arithmetic (Euclid’s algorithm); no rounding.

Source formulas: the standard textbook definitions written out in the Formula section above. Every value in the tables was generated from those formulas in code and spot-checked against the worked example and the calculator on this page; nothing was copied from another table.

Related

Formula used
in a | First number a | - | 18 | 1 | -
in b | Second number b | - | 24 | 1 | -
in gg | Their GCD (from the table) | - | 6 | 1 | -
out l | LCM = a·b / GCD | - | a * b / gg | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More on this panel

The whole Numbers and Counting panel →