GCD and LCM Calculator
Greatest common divisor and least common multiple of 2–4 whole numbers, with Euclid's algorithm written out line by line and the prime factorizations.
GCD and LCM Calculator: with the default inputs, greatest common divisor (gcd / gcf) is 6.
Numbers 3 and 4 live under More options.
- Least common multiple (LCM)
- 144
- Coprime?
- No — they share the factor 6Numbers are coprime (relatively prime) when their GCD is 1.
Assumptions
- Signs are ignored (GCD and LCM of absolute values).
- Arithmetic is exact with arbitrary-precision integers; prime factorizations are shown for numbers up to 10¹².
| Number | Prime factors |
|---|---|
| 48 | 2⁴ × 3 |
| 18 | 2 × 3² |
GCD takes the lowest power of each shared prime; LCM takes the highest power of every prime that appears.
How this is worked out
The formula
Euclid: GCD(a, b) = GCD(b, a mod b), repeat until the remainder is 0; the last non-zero remainder is the GCD LCM(a, b) = a × b ÷ GCD(a, b) For more numbers: GCD(a, b, c) = GCD(GCD(a, b), c), LCM(a, b, c) = LCM(LCM(a, b), c)
Open How it’s calculated above to see this worked through with your own numbers.
What you enter
- How many numbers?
- Numbers 3 and 4 live under More options.from 2 to 4 · whole numbers only · defaults to 2
- First number
- A number.whole numbers only · defaults to 48
- Second number
- A number.whole numbers only · defaults to 18
- Third number(under More options)
- Used when 'How many numbers' is 3 or more.whole numbers only · defaults to 0
- Fourth number(under More options)
- Used when 'How many numbers' is 4.whole numbers only · defaults to 0
What you get back
- Greatest common divisor (GCD / GCF)main answer
- Least common multiple (LCM)
- Coprime?
- Numbers are coprime (relatively prime) when their GCD is 1.
What this assumes
- Signs are ignored (GCD and LCM of absolute values).
- Arithmetic is exact with arbitrary-precision integers; prime factorizations are shown for numbers up to 10¹².
About this calculator
The greatest common divisor (also called the greatest common factor or highest common factor) is the largest whole number that divides all of your numbers with nothing left over. The least common multiple is the smallest whole number that all of them divide into. GCD is what you use to simplify fractions and ratios; LCM is what you need for a common denominator, or for "when will these two events line up again?" problems.
How to use it
Enter two numbers (or set the count to 3 or 4 and open More options for the rest). The steps show Euclid's algorithm line by line — the same working a teacher expects — and the table shows each number's prime factorization so you can see the answer a second way.
Euclid's algorithm
Listing every factor works for small numbers but not for 4,829 and 2,231. Euclid's trick: any common divisor of a and b also divides the remainder when you divide a by b. So GCD(48, 18) = GCD(18, 12) = GCD(12, 6) = GCD(6, 0) = 6. Each step shrinks the numbers fast — it needs only about five divisions per digit — and it's still the algorithm computers use.
GCD and LCM are partners
For two numbers, GCD × LCM = a × b. That's why the calculator finds the LCM as a × b ÷ GCD rather than listing multiples. In prime-factor terms, the GCD takes the lowest power of each shared prime and the LCM takes the highest power of every prime present: 48 = 2⁴ × 3 and 18 = 2 × 3², so GCD = 2 × 3 = 6 and LCM = 2⁴ × 3² = 144.
Three or more numbers
Fold them in one at a time: GCD(a, b, c) = GCD(GCD(a, b), c), and the same for LCM. The product shortcut only holds for two numbers, though — GCD × LCM ≠ a × b × c in general.
Common mistakes
- Mixing them up: the GCD is never bigger than the smallest input; the LCM is never smaller than the largest.
- Using the product as a common denominator when the LCM is smaller (24 and 36 have LCM 72, not 864).
- Including 0. Every number divides 0, so GCD(a, 0) = a, but LCM with 0 is 0 by convention — the calculator asks for positive inputs instead.
Frequently asked questions
▸How do I find the GCD by hand?
Use Euclid's algorithm: divide the larger by the smaller, replace the larger with the remainder, repeat until the remainder is 0. The last non-zero remainder is the GCD. For 48 and 18: 48 = 2×18 + 12, 18 = 1×12 + 6, 12 = 2×6 + 0, so GCD = 6.
▸How do I find the LCM?
Multiply the two numbers and divide by their GCD: LCM(48, 18) = 48 × 18 ÷ 6 = 144. For more numbers, take the LCM of the first two, then combine it with the next.
▸What's the difference between GCF, GCD and HCF?
Nothing — greatest common factor, greatest common divisor and highest common factor are three names for the same thing.
▸What does it mean if the GCD is 1?
The numbers are coprime (relatively prime): they share no factor other than 1. A fraction with coprime top and bottom is already in lowest terms.
Put this calculator on your own site
A working gcd & lcm, free for any site, with no ads and no sign-up. It resizes to fit wherever you paste it and updates itself as this page improves.
Paste this anywhere. It works on any site, carries no ads, never expires, and always shows the current version.
GCD and LCM Calculator by CalculateItNow
The page's own title. The clearest description of what the link leads to.
The credit line sits outside the widget on purpose, so it is a real link on your page rather than one buried in a frame. Please keep it — it is what pays for CalculateItNow staying free and ad-free. The script only resizes the widget to fit its contents; drop it and the widget still works.
Browse every calculator widget·How to add it to WordPress, Squarespace or Wix
Related calculators
The questions people ask next to a gcd & lcm.
Add, subtract, multiply and divide fractions and mixed numbers — exact simplified answers with the common denominator and every step shown.
Test any number up to a trillion for primality, get its full factorisation, the nearest primes either side, and how many primes lie below it.
a mod b with the quotient and remainder, showing where the mathematical modulo and the % operator in C, Java and JavaScript disagree on negative numbers.
Simplify a ratio, solve a proportion (A:B = C:?) or split a total in a given ratio — with the GCD, cross-multiplication and each part shown.
Square roots, cube roots and nth roots with the radical simplified (√72 = 6√2) via prime factorization, plus the number squared and cubed.
nCr and nPr, with or without repetition — exact answers for huge counts, the formula substituted, and a plain explanation of when order matters.
Divide with the full long-division layout: every bring-down, each quotient digit, the remainder, and the decimal with its repeating block marked.