GCD finds the largest number that divides into several values evenly; LCM finds the smallest number they all divide into. They’re the tools for simplifying ratios and lining up repeating cycles.
The example
GCD and LCM of pairs of numbers.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | a | b | GCD | LCM |
| 2 | 12 | 18 | 6 | 36 |
| 3 | 8 | 12 | 4 | 24 |
The formula
GCD and LCM:
How it works
Two complementary divisibility tools:
GCD(a, b)returns the greatest common divisor — the biggest number that divides both evenly (6 for 12 and 18).LCM(a, b)returns the least common multiple — the smallest number both divide into (36).- Both take more than two arguments:
GCD(12, 18, 24)works. - A key use: simplify a ratio by dividing both parts by their GCD — 12:18 becomes 2:3.
Simplify a ratio in one shot: =A2/GCD(A2,B2) & ":" & B2/GCD(A2,B2) turns 12 and 18 into the text 2:3 — handy for aspect ratios and recipe scaling.
Try it: interactive demo
Enter two numbers.
Variations
Simplify a ratio
Divide both by the GCD:
GCD of several numbers
Pass a range:
When do two cycles align?
LCM of the periods:
Pitfalls & errors
Whole numbers only. GCD and LCM truncate decimals to integers. Scale up first if you’re working with fractions.
#NUM! on negatives. Both expect non-negative values; negative inputs error. Use ABS if signs may vary.
LCM can get huge fast. The LCM of several large coprime numbers explodes — and may exceed Excel’s number precision.
Practice workbook
Frequently asked questions
How do I find the greatest common divisor in Excel?
How do I simplify a ratio in Excel?
What is LCM used for?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class