LCM & GCF Calculator
Find the least common multiple (LCM) and greatest common factor (GCF) of two or more whole numbers, with the Euclidean and prime-factorisation methods explained step by step.
Updated 2026-06-09 · Free · No sign-up · Runs privately in your browser
What is an LCM and GCF calculator?
An LCM and GCF calculator finds the least common multiple (LCM) and greatest common factor (GCF) of any set of two or more whole numbers. The GCF is the largest number that divides every value exactly, and the LCM is the smallest number that every value divides into. Enter your numbers — separated by commas or spaces — press Calculate, and the tool returns both results at once. For 12, 18 and 24 it shows a GCF of 6 and an LCM of 72.
These two ideas sit at the heart of fraction arithmetic, scheduling problems and number theory, so a quick calculator saves a lot of pencil-and-paper work. If you only need one of the two, the same answers apply.
How does this calculator work?
The tool computes the GCF first using the Euclidean algorithm, then derives the LCM from it. The GCF of a whole list is found by combining numbers two at a time, and so is the LCM, using the relationship below.
The exact method the widget uses:
- GCF of a pair: repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder is 0. The last non-zero value is the GCF.
- GCF of a list: take the GCF of the first two numbers, then the GCF of that result with the next number, and so on.
- LCM of a pair:
LCM(a, b) = (a × b) ÷ GCF(a, b). - LCM of a list: combine pairwise —
LCM(a, b, c) = LCM( LCM(a, b), c ).
Because the LCM is built from the GCF, both figures are always perfectly consistent with each other.
How do you work out the GCF and LCM of 12, 18 and 24?
The GCF is 6 and the LCM is 72. Here is the full worked example, exactly matching the calculator.
Step 1 — GCF of 12 and 18 (Euclidean algorithm):
- 18 ÷ 12 leaves remainder 6
- 12 ÷ 6 leaves remainder 0 → GCF(12, 18) = 6
Step 2 — GCF of that result with 24:
- GCF(6, 24): 24 ÷ 6 leaves remainder 0 → GCF = 6
So the GCF of 12, 18 and 24 is 6.
Step 3 — LCM, built pairwise:
- LCM(12, 18) = (12 × 18) ÷ 6 = 216 ÷ 6 = 36
- LCM(36, 24) = (36 × 24) ÷ GCF(36, 24) = 864 ÷ 12 = 72
So the LCM of 12, 18 and 24 is 72. You can check it: 72 ÷ 12 = 6, 72 ÷ 18 = 4 and 72 ÷ 24 = 3 — all whole, and no smaller number works.
What does a second worked example look like?
Take 4, 6 and 8. The GCF is 2 and the LCM is 24.
| Step | Calculation | Result |
|---|---|---|
| GCF of 4 and 6 | 6 ÷ 4 r2, then 4 ÷ 2 r0 | 2 |
| GCF with 8 | GCF(2, 8) = 2 | 2 |
| LCM of 4 and 6 | (4 × 6) ÷ 2 = 24 ÷ 2 | 12 |
| LCM with 8 | (12 × 8) ÷ GCF(12, 8) = 96 ÷ 4 | 24 |
A quick contrast: 7 and 13 are both prime, share no common factor, and so have a GCF of 1. They are coprime, which makes their LCM simply 7 × 13 = 91.
What is the prime-factorisation method?
The prime-factorisation method gives the same answers and is handy for checking by hand. Break each number into its prime factors, then read off the GCF and LCM from the powers of each prime.
- GCF: multiply each shared prime using its lowest power across all numbers.
- LCM: multiply every prime that appears using its highest power across all numbers.
Using 12, 18 and 24:
| Number | Prime factorisation |
|---|---|
| 12 | 2² × 3 |
| 18 | 2 × 3² |
| 24 | 2³ × 3 |
For the GCF, the lowest power of 2 is 2¹ and the lowest power of 3 is 3¹, so GCF = 2 × 3 = 6. For the LCM, the highest power of 2 is 2³ and of 3 is 3², so LCM = 8 × 9 = 72 — the same results the Euclidean route gave.
What is the difference between LCM and GCF?
The GCF goes down into the numbers and the LCM goes up. The GCF is never larger than your smallest input, while the LCM is never smaller than your largest input. This quick reference shows the contrast:
| GCF (greatest common factor) | LCM (least common multiple) | |
|---|---|---|
| Also called | HCF, GCD | LCD when used for fractions |
| Finds | Largest shared divisor | Smallest shared multiple |
| Relative size | ≤ smallest number | ≥ largest number |
| Common use | Simplifying fractions, sharing into equal groups | Adding fractions, repeating events |
| For 12, 18, 24 | 6 | 72 |
What are common uses for LCM and GCF?
Both turn up constantly in everyday maths:
- Simplifying fractions — divide the numerator and denominator by their GCF to get lowest terms. Our mixed number calculator and ratio calculator rely on the same idea.
- Adding or subtracting fractions — the LCM of the denominators is the least common denominator (LCD).
- Scheduling and cycles — if one event repeats every 12 days and another every 18, they coincide every LCM(12, 18) = 36 days.
- Sharing into equal groups — the GCF tells you the largest equal group size that uses every item with none left over.
- Tiling and packing — the LCM finds the smallest square or length that two tile sizes both fit exactly.
What tips and common mistakes should I know?
A few pointers help you trust the result:
- Sanity-check the size. The GCF can never exceed your smallest number, and the LCM can never be smaller than your largest. If you see otherwise, something is off.
- GCF of 1 is normal. It just means the numbers are coprime; the LCM is then their product.
- Order does not matter. GCF and LCM are the same whatever order you type the numbers in.
- Watch the multiplication. When doing it by hand, the LCM formula is
(a × b) ÷ GCF, nota × b ÷ a × b. - Only whole numbers count. The tool ignores decimals, fractions, zero and negatives, so enter clean positive integers. You need at least two valid numbers for an answer.
For more whole-number tools, browse the full math calculators category, including the square root calculator and mean, median and mode calculator.
Are there any limitations?
This calculator is built for positive whole numbers only. It does not handle fractions, decimals, zero or negative values, and it will not factor numbers so large that they exceed standard number precision. For exact results, keep your inputs to ordinary integers — the kind you meet in schoolwork, fractions and scheduling. The method and figures here are for general mathematical and educational use; always double-check any value that feeds into important calculations.
Frequently asked questions
What is the difference between LCM and GCF?+
The GCF (greatest common factor) is the largest number that divides all your numbers exactly, while the LCM (least common multiple) is the smallest number that all of them divide into. GCF is always less than or equal to the smallest input; LCM is always greater than or equal to the largest input.
How do you find the GCF of two numbers?+
Use the Euclidean algorithm — repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder is zero. The last non-zero number is the GCF. For example, GCF(12, 18) = 6.
How do you find the LCM?+
For two numbers, LCM equals their product divided by their GCF, so LCM(a, b) = a times b divided by GCF(a, b). For three or more numbers, combine them two at a time, carrying the running result forward.
What is the GCF and LCM of 12, 18 and 24?+
The GCF is 6 and the LCM is 72. Six is the largest number that divides 12, 18 and 24, and 72 is the smallest number that 12, 18 and 24 all divide into.
Is HCF the same as GCF?+
Yes. HCF (highest common factor) and GCD (greatest common divisor) are different names for the GCF (greatest common factor). All three mean the largest number that divides every value in the set.
What does it mean when the GCF is 1?+
When the GCF equals 1, the numbers share no common factor other than 1 and are called coprime or relatively prime. In that case the LCM is simply the product of the numbers, as with 7 and 13 whose LCM is 91.
Can LCM and GCF work with three or more numbers?+
Yes. This calculator accepts any list of two or more positive whole numbers separated by commas or spaces and combines them pairwise to return one GCF and one LCM for the whole set.
Why must the inputs be positive whole numbers?+
LCM and GCF are defined for positive integers. The calculator ignores decimals, fractions, zero and negatives, and needs at least two valid whole numbers to produce a result.