Glossary Math & Statistics

Least common multiple (LCM)

The least common multiple of two numbers is the smallest positive number that both divide into evenly.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page

In more detail

lcm(a, b) = a × b / gcd(a, b), so lcm(12, 18) = 216 / 6 = 36. Using prime factors, take every prime that appears in either number at its highest power: 12 = 2² × 3 and 18 = 2 × 3² give 2² × 3² = 36. For more than two numbers, apply it repeatedly: lcm(4, 6, 10) = lcm(lcm(4, 6), 10) = lcm(12, 10) = 60.

Why it matters

It is the smallest common denominator needed to add fractions, and the interval after which two repeating cycles line up again: timetables, gear teeth, planetary alignments, scheduled jobs. Multiplying the numbers together always gives a common multiple, but not the smallest one, which makes fraction arithmetic messier than it needs to be.

Example

One bus leaves every 12 minutes and another every 18 minutes, both at 8:00. They next leave together after lcm(12, 18) = 36 minutes, at 8:36.

>>> import math
>>> math.lcm(12, 18), math.lcm(4, 6, 10)
(36, 60)
>>> math.gcd(12, 18) * math.lcm(12, 18) == 12 * 18
True

(math.lcm exists from Python 3.9.)

Common confusion

The Greatest common factor (GCF) goes the other way: the largest number dividing both. For two numbers, GCF × LCM always equals their product: 6 × 36 = 216 = 12 × 18.

AdSense Placeholder
Slot: footer_leaderboard