How it works
The GCD is the largest whole number that divides evenly into both numbers, found using the Euclidean algorithm.
The LCM is the smallest whole number that both numbers divide evenly into, found from the GCD: (first number ÷ GCD) × second number.
The Euclidean algorithm finds the GCD by repeated division rather than by testing every candidate factor. For 84 and 126, dividing 126 by 84 leaves a remainder of 42; dividing 84 by that 42 leaves a remainder of zero, so the last non-zero remainder, 42, is the GCD. The LCM then follows in one step: (84 ÷ 42) × 126 = 2 × 126 = 252.
Formula: LCM = (first number ÷ GCD) × second number
Examples
Two numbers with common factors
12 and 18 have a GCD of 6 and an LCM of 36.
Two coprime numbers
4 and 7 share no common factor other than 1, so their GCD is 1 and their LCM is their product, 28.
Large numbers with a large common factor
3,600 and 4,800 share a GCD of 1,200, and their LCM is 14,400, which is four times the smaller input and three times the larger.
One number divides the other
When one value divides evenly into the other, the GCD is the smaller number and the LCM is the larger: 24 and 6 give a GCD of 6 and an LCM of 24.
Common uses
- Reducing a ratio or a pair of quantities to their simplest form, since the GCD divides both sides — simplifying a ratio is the same reduction.
- Timing two repeating cycles so that they coincide: a 15-minute timer and a 21-minute timer next chime together after 105 minutes, the shortest interval both cover exactly.
- Scaling two quantities up to a whole number of equal portions, so a batch of 4 and a batch of 6 both divide neatly into 12 equal parts.
- Reducing a fraction by hand, such as 14/84 simplified to 1/6 by dividing the numerator and the denominator by their GCD of 14.
Things to keep in mind
- Both numbers must be positive whole numbers.
- "HCF" (highest common factor) is another name for the same thing as GCD — the two terms are used in different regions for an identical calculation.
- Decimals are rejected rather than rounded, so entering 12.5 raises an error instead of quietly using 12 or 13.
- The least common multiple is refused once either input passes 9,007,199,254,740,991, the largest whole number a JavaScript calculation can hold exactly, because an LCM is usually far larger than either input.
- Results are rounded to 12 significant digits and displayed to at most 10 decimal places, so a long least common multiple can be rounded even when both inputs are held exactly.