GCD + LCM of any list of integers — Euclidean steps, prime factorization, prime-factor table — exact BigInt math, browser-only
- Runs locally
- Category Calculator
- Best for Getting a realistic range before a purchase, plan, workout, or schedule decision.
Separate with commas, spaces, or new lines — e.g. 12, 18, 30
Euclidean algorithm
Step-by-step for the first pair (pair: 12, 18)
- 18 = 1 × 12 + 6
- 12 = 2 × 6 + 0
Remainder is 0 → the previous divisor is the GCD.
Prime factorization
- 12=2^2 · 3
- 18=2 · 3^2
- 30=2 · 3 · 5
Prime-factor method
GCD takes the lowest power of each shared prime; LCM takes the highest power of every prime.
| Prime | 12 | 18 | 30 | min → GCD | max → LCM |
|---|---|---|---|---|---|
| 2 | ^2 | ^1 | ^1 | ^1 | ^2 |
| 3 | ^1 | ^2 | ^1 | ^1 | ^2 |
| 5 | — | — | ^1 | ^0 | ^1 |
What this tool does
Find the greatest common divisor (GCD) and least common multiple (LCM) of two or more positive integers, and actually see how the answer is reached. Type a list like 12, 18, 30 and you get the GCD and the LCM, plus three worked views that most calculators skip: the full Euclidean algorithm step table (every a = q·b + r row for the first pair), the prime factorization of every number you entered (e.g. 360 = 2^3 · 3^2 · 5), and a prime-factor method grid where GCD takes the lowest power of each shared prime and LCM takes the highest power of every prime. All math runs on BigInt, so 15-digit inputs stay exact instead of rounding into floating-point error, and the LCM divides before it multiplies so the intermediate value never overflows. Separate numbers with commas, spaces, or new lines; non-integer, negative, or zero inputs get a clear message instead of a wrong answer. Nothing is uploaded — the whole thing is JavaScript in your tab, and the input rides along in the URL so a share link reproduces the exact same calculation. Built for the moment you need both the number and the reasoning behind it.
Tool details
- Input
- Text
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy + Preview
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 10 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Calculator · Student
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How GCD & LCM Calculator fits into your work
Use it for fast estimates, comparisons, and planning numbers before you make the final call.
Calculation jobs
- Getting a realistic range before a purchase, plan, workout, or schedule decision.
- Comparing scenarios by changing one input at a time.
- Turning rough assumptions into a number you can discuss.
Calculation checks
- Double-check units, dates, rates, and rounding assumptions.
- Treat health, finance, tax, and legal outputs as planning aids, not professional advice.
- Save the inputs that produced an important result so you can reproduce it later.
Good next steps
These links move the current task into a more complete workflow.
- 1 Scientific Calculator Scientific calculator — sin / cos / log / sqrt / power, with full keyboard input + history, deg/rad mode. Open
- 2 Number Base Converter Number base converter — binary, octal, decimal, hex, and any base 2-36. Bitwise too. Open
- 3 Statistics Basic Calculator Basic statistics calculator — mean/median/mode/variance/std-dev/quartiles/range/IQR/skewness/kurtosis + histogram + box plot, paste any numbers. Open
Real-world use cases
Add fractions with unlike denominators
To add 5/12 + 7/18 you need a common denominator, and the cleanest choice is the LCM of 12 and 18. Type "12, 18" — the LCM is 36. Now rewrite: 5/12 = 15/36 and 7/18 = 14/36, so the sum is 29/36. The prime-factor grid makes the why obvious: 12 = 2^2·3, 18 = 2·3^2, and the LCM takes the highest power of each prime (2^2·3^2 = 36). Using 36 instead of the lazy 12×18 = 216 keeps the numbers small and the final fraction already close to lowest terms.
Reduce a fraction to lowest terms
A fraction like 360/420 looks ugly until you divide top and bottom by their GCD. Type "360, 420" — the GCD is 60. So 360/420 = (360÷60)/(420÷60) = 6/7, fully reduced in one step. The Euclidean step table shows exactly how 60 falls out (420 = 1×360 + 60, then 360 = 6×60 + 0), which is handy when a teacher wants the working shown, not just the answer.
Find when two repeating events line up again
Bus A leaves every 12 minutes, Bus B every 18 minutes, both at 8:00. When do they next depart together? That's the LCM of 12 and 18 = 36, so 8:36, then every 36 minutes after. The same shape solves "two cron jobs at 15 and 20 minute intervals — when do they collide?" (LCM 60, so every hour) and "gear teeth meshing back to the start". Type the two intervals and read the LCM.
Size gear ratios and pulley systems
Two meshing gears with 24 and 36 teeth return to their starting alignment after LCM(24, 36) = 72 teeth pass the contact point — that's 3 turns of the small gear and 2 of the big one. The GCD (12) tells you the largest gear you could swap both for while keeping the ratio. Type "24, 36" and both numbers are right there, with the factorization showing why (24 = 2^3·3, 36 = 2^2·3^2).
Schedule overlapping recurring tasks
You run a report every 6 days, a backup every 8 days, and an audit every 9 days, all starting today. The next day all three land together is LCM(6, 8, 9) = 72 days out. Type "6, 8, 9" and the LCM is computed across the whole set, not just a pair, so you can plan capacity for the day everything stacks up. The prime-factor grid (2^3·3^2 = 72) shows the backup's factor of 8 is what pushes the cycle out.
Common pitfalls
Adding percentages or discounts is not the same as adding the numbers, and neither is "adding" denominators when you add fractions — you need the LCM of the denominators, not their sum or product. 1/12 + 1/18 uses 36 (the LCM), not 30 (the sum) and not 216 (the product). Using the product still gives a correct fraction, just not in lowest terms; using the sum gives a flatly wrong answer.
GCD × LCM = a × b holds for two numbers only. People try to extend it to three numbers as GCD × LCM = a × b × c — it doesn't. For 4, 6, 8: GCD = 2, LCM = 24, product = 192, but 2 × 24 = 48 ≠ 192. For three or more numbers, compute GCD and LCM directly from the prime-factor grid (min and max exponents), which is what this tool does.
Treating LCM as "just multiply them all together" wastes the whole point. 12 and 18 multiply to 216, but their LCM is 36 — six times smaller. The product is always a common multiple, but rarely the least one. Use the LCM whenever you want the smallest fitting number (smallest common denominator, soonest overlap day, fewest gear teeth).
Privacy
Every step — parsing your list, the Euclidean algorithm, the prime factorization, the prime-factor grid — is plain JavaScript running in your browser tab. No number is uploaded, no analytics records what you computed. The one privacy note: the numbers you enter are encoded into the URL query string so a "share" link reopens the same calculation. For ordinary math that's the point; if your inputs are sensitive (an account ID, a quantity you'd rather not leak), copy the result instead of sharing the URL, since the destination server's access log would otherwise record the numbers.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- Chinese Acupoint Locator 200+ meridian acupoints / WHO 2008 standard locations / with contraindications, manipulation, and combinations.
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only
- Anagram Solver Check if two words are anagrams, rearrange a set of letters into every ordering, and read the sorted letter fingerprint, all in your browser
- Angle Converter Degrees, radians, gradians, turns, arcminutes, arcseconds and NATO mils, all from one input, copyable, browser-only