The greatest common divisor (GCD) is the largest positive integer dividing every given number. The least common multiple (LCM) is their smallest shared positive multiple. For 12 and 18, the GCD is 6 and the LCM is 36.

This guide uses positive integers. Learn which quantity a problem needs, follow the working and check examples with the GCD and LCM Calculator.

Choose GCD or LCM from the problem

Goal Use Example with 12 and 18
Simplify a fraction GCD Divide both terms of 12/18 by 6 to get 2/3
Find a common denominator LCM 1/12 = 3/36 and 1/18 = 2/36
Make the largest equal pieces with no remainder GCD Cut 12 cm and 18 cm into 6 cm pieces
Find when synchronized cycles next coincide LCM 12-minute and 18-minute cycles meet after 36 minutes

The divisors of 12 are 1, 2, 3, 4, 6, 12; those of 18 are 1, 2, 3, 6, 9, 18. The largest shared divisor is 6. The multiple lists 12, 24, 36, … and 18, 36, 54, … first meet at 36.

Use prime exponents

OpenStax explains prime factorization and LCM. Arrange exponents in columns; an absent prime has exponent zero. For help factoring a number, see the prime factorization guide.

Number Exponent of 2 Exponent of 3 Exponent of 5
24 = 2³ × 3 3 1 0
36 = 2² × 3² 2 2 0
60 = 2² × 3 × 5 2 1 1
GCD: minimum in each column 2 1 0
LCM: maximum in each column 3 2 1

Thus GCD = 2²×3 = 12 and LCM = 2³×3²×5 = 360. Since only 60 contains the factor 5, it cannot be part of a divisor shared by all three.

Euclidean algorithm: 48 and 18

Repeat division using the previous divisor and remainder:

  1. 48 = 18×2 + 12
  2. 18 = 12×1 + 6
  3. 12 = 6×2 + 0

The divisor in the final line is 6, the GCD. The final remainder zero is not the answer.

Why does this work? If A = B×q + r, any common divisor of A and B also divides r; any common divisor of B and r also divides A. The shared divisors stay the same. Repeating this property is the Euclidean algorithm.

Obtain the LCM from the GCD

For two positive integers, LCM(A,B) = A×B/GCD(A,B). For 48 and 18 this is 48×18/6 = 144. Check that 6 divides both inputs and 144 is a multiple of both.

Computing (A/GCD)×B keeps intermediate products smaller in an implementation. This site’s calculator uses BigInt integer arithmetic, with explicit input limits.

Do not apply the two-number product formula to three numbers

Multiplying all three inputs and dividing by their GCD does not generally give their LCM. For 24, 36 and 60, that calculation gives 4320, but the LCM is 360.

Stage GCD LCM
Combine 24 and 36 GCD(24,36) = 12 24×36/12 = 72
Combine each result with 60 GCD(12,60) = 12 GCD(72,60) = 12, so 72×60/12 = 360

Carry forward the separate intermediate results for GCD and LCM. Do not reuse the running GCD as the running LCM. The calculator displays the two LCM stages for comparison with this table.

Word problems: equal pieces and repeating events

Cut 12 cm and 18 cm lengths into equal pieces

Ignoring material lost in cutting, the largest equal pieces with no leftover length are 6 cm, the GCD. The lengths make two and three pieces respectively.

For tiling, the precise problem is: cover a 12 cm by 18 cm rectangle with identical square tiles, aligned to its edges, with no gaps or grout. The largest tile side is 6 cm and the count is (12/6)×(18/6) = six. This does not answer a different problem about constructing the smallest square from tiles of widths 12 cm and 18 cm.

When do 12-minute and 18-minute cycles next coincide?

If both start at time zero and repeat at constant intervals, their next shared event is after 36 minutes, the LCM.

Events at 0, 12, 24 and 36 minutes compared with events at 0, 18 and 36. The first shared event after the common start is at 36 minutes.
Figure 1. Constant cycles with a shared start and time axis. Original teaching plot by Tools Hub. Enlarge the plot

The first sequence is 0, 12, 24, 36 minutes; the second is 0, 18, 36. Zero is the common start, so the next match is 36. If their start times differ, the LCM alone does not determine the next match. For example, starting the second sequence three minutes later produces no coincidence in this integer-minute model.

Coprime does not mean both numbers are prime

Numbers are coprime when their GCD is 1. Both 8 and 15 are composite, but they are coprime, giving LCM = 8×15 = 120.

A group GCD of 1 does not mean every pair is coprime. The numbers 6, 10 and 15 have group GCD 1, but their pairs share factors 2, 3 and 5. Their LCM is 30, not their product 900.

Reproduce the examples in the calculator

The GCD and LCM Calculator accepts two or three positive integers. Leave C empty for a two-number calculation.

A B Optional C GCD LCM
12 18 Empty 6 36
48 18 Empty 6 144
24 36 60 12 360
6 10 15 1 30
8 15 Empty 1 120

Each input must be between 1 and 1,000,000,000,000. Do not use grouping commas, decimals, negative numbers or zero. Output grouping commas are formatting: remove them when re-entering a number. Compare the working as well as the final numbers. For the fraction application, continue to common denominators and simplification.

Practice with answers

  1. 18 and 30: GCD 6, LCM 90.
  2. 16, 24 and 40: GCD 8, LCM 240.
  3. Synchronized 8-minute and 12-minute cycles: next match after 24 minutes.
  4. Largest identical square tiles covering an 18 cm by 30 cm rectangle: side 6 cm, 15 tiles, with no grout or gaps.

Frequently asked questions

Are zero and negative numbers invalid in mathematics too?

This guide and tool are limited to positive integers. Mathematical definitions can extend to zero and negatives; that is separate from the tool’s input rules.

What if the inputs are equal?

GCD(12,12) and LCM(12,12) are both 12. A common divisor need not be strictly smaller than the inputs.

Can I use 1?

For a positive integer n, GCD(1,n) = 1 and LCM(1,n) = n. One is not prime, but is a valid input here.

What was checked

On October 7, 2026, the factorization and Euclidean-algorithm references were reviewed and examples recalculated with integer arithmetic. The original plot represents hypothetical periodic events. The ambiguous tiling problem was corrected, and the calculator’s three-input LCM working was corrected and checked against the actual pairwise calculation.