How to Calculate GCD and LCM (with Examples)

Learn how to find the Greatest Common Divisor and Least Common Multiple of any two numbers.

The Quick Answer

GCD (Greatest Common Divisor): The largest number that divides both numbers evenly.

LCM (Least Common Multiple): The smallest number that both numbers divide into evenly.

Numbers GCD LCM
12 and 18 6 36
15 and 20 5 60
7 and 11 1 77

Finding GCD: The Euclidean Algorithm

The fastest method for finding GCD:

  1. Divide the larger number by the smaller
  2. Take the remainder
  3. Replace the larger with the smaller, smaller with remainder
  4. Repeat until remainder is 0
  5. The last non-zero value is the GCD

Example: GCD of 48 and 18

48 ÷ 18 = 2 remainder 12
18 ÷ 12 = 1 remainder 6
12 ÷ 6 = 2 remainder 0

GCD = 6

Example: GCD of 56 and 42

56 ÷ 42 = 1 remainder 14
42 ÷ 14 = 3 remainder 0

GCD = 14

Finding GCD: Prime Factorization

Another method using prime factors:

  1. Find prime factors of each number
  2. Identify common factors
  3. Multiply the common factors together

Example: GCD of 36 and 48

36 = 2 × 2 × 3 × 3 = 2² × 3²
48 = 2 × 2 × 2 × 2 × 3 = 2⁴ × 3

Common: 2² × 3 = 4 × 3 = 12

GCD = 12

Finding LCM

Method 1: Using GCD

The fastest way once you have GCD:

LCM(a, b) = (a × b) / GCD(a, b)

Example: LCM of 12 and 18

GCD(12, 18) = 6
LCM = (12 × 18) / 6 = 216 / 6 = 36

Method 2: Prime Factorization

  1. Find prime factors of each number
  2. Take the highest power of each prime
  3. Multiply them together

Example: LCM of 12 and 18

12 = 2² × 3
18 = 2 × 3²

Take highest powers:
- 2²  (from 12)
- 3²  (from 18)

LCM = 2² × 3² = 4 × 9 = 36

GCD and LCM Relationship

For any two numbers a and b:

GCD(a, b) × LCM(a, b) = a × b

This is useful for checking your work:

  • 12 × 18 = 216
  • 6 × 36 = 216 ✓

When GCD = 1

Two numbers with GCD = 1 are called coprime or relatively prime.

Examples:

  • 7 and 11 (both prime)
  • 8 and 15 (no common factors)
  • 14 and 25 (no common factors)

For coprime numbers: LCM(a, b) = a × b

Practical Applications

GCD Uses

Application Example
Simplifying fractions 12/18 → 2/3 (divide by GCD 6)
Cutting equal pieces Cut 48cm and 18cm ropes into equal lengths
Tiling Fit tiles evenly in a room

LCM Uses

Application Example
Adding fractions 1/4 + 1/6 needs denominator 12
Scheduling Events every 3 and 4 days meet at day 12
Gear ratios When do two gears align?

Examples

Simplifying Fractions

Simplify 24/36:

GCD(24, 36) = 12
24/36 = (24÷12)/(36÷12) = 2/3

Finding Common Denominators

Add 1/4 + 1/6:

LCM(4, 6) = 12
1/4 = 3/12
1/6 = 2/12
3/12 + 2/12 = 5/12

Multiple Numbers

For three or more numbers, apply iteratively:

GCD(12, 18, 24)
= GCD(GCD(12, 18), 24)
= GCD(6, 24)
= 6

LCM(4, 6, 8)
= LCM(LCM(4, 6), 8)
= LCM(12, 8)
= 24
Calculate Instantly

GCD & LCM Calculator

Find the greatest common divisor and least common multiple of any two numbers.

Open Calculator

Related Tools

Related Tools