Skip to content
Calcuplay
Math

GCD and LCM calculator

Enter your whole numbers: the GCD (greatest common divisor, also called GCF) and the LCM (least common multiple) show, with the prime factorization and Euclid's steps.

Separated by spaces or commas, for example 12, 18, 30.

GCD

6

LCM

36

Prime factorization

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

Euclid's algorithm

  1. 18 = 1 × 12 + 6
  2. 12 = 2 × 6 + 0
In the middle, the shared factors: their product is the GCD. All the factors together give the LCM.

Quick challenge

Streak 0Best 0

Test yourself: every answer is computed by the tool, and the wrong choices are the most common traps.

How it works

Formula: LCM(a, b) = a × b ÷ GCD(a, b)

The GCD is the largest number that divides all your numbers; the LCM is the smallest number they all divide. Euclid's algorithm finds the GCD by repeated division: divide the larger by the smaller, then the divisor by the remainder, until the remainder is zero. For two numbers, GCD × LCM = a × b. The prime factorization shows why: the GCD takes the shared factors, the LCM all of them.

Worked examples

  • GCD and LCM of 12 and 18

    GCD 6, LCM 36: 12 = 2² × 3 and 18 = 2 × 3².

  • Simplifying the fraction 84/126

    The GCD of 84 and 126 is 42: the fraction becomes 2/3.

  • Two buses, every 12 and 20 minutes

    They come together every 60 minutes: that's the LCM.

Common mistakes

  • Mixing up GCD and LCM.

    The GCD divides every number, so it is smaller; the LCM is a multiple of all of them, so it is larger.

  • Taking the product as the LCM: 12 × 18 = 216.

    The LCM of 12 and 18 is 36: divide the product by the GCD.

  • Thinking the GCD of 8 and 15 is 0.

    It is 1: these numbers are coprime.

GCD and LCM of common pairs

GCD and LCM of common pairs
NumbersGCDLCM
6, 8224
8, 12424
9, 12336
12, 18636
14, 21742
15, 25575
16, 24848
18, 24672
20, 301060
24, 361272
36, 4812144
45, 6015180

Frequently asked questions

How do you find the GCD?

With Euclid's algorithm: 18 = 1 × 12 + 6, then 12 = 2 × 6 + 0. The last non-zero remainder, 6, is the GCD.

How are GCD and LCM related?

For two numbers, their product equals GCD × LCM: 12 × 18 = 6 × 36.

How many numbers can I enter?

From 2 to 10 whole numbers, from 1 to 1 billion.

Math calculators

Math calculators

Other calculators