The greatest common factor (GCF, also called the greatest common divisor or GCD) and the least common multiple (LCM) of two or more integers, computed exactly and shown two ways at once: the GCD by the Euclidean algorithm with every division step printed, and both answers rebuilt from the prime factorizations so the two methods can be checked against each other. Signs and zeros follow the standard conventions and are stated rather than hidden, and for two numbers the identity GCD × LCM = a × b is verified on the page.
Separate the numbers with commas or spaces. Integers only, each up to 999,999,999,999 in size (the cap keeps prime factorization instant); a minus sign is accepted and ignored, because both answers are reported as positive numbers by convention.
How to use this calculator
- Enter two or more integers, separated by commas or spaces, and calculate.
- Read the GCD and LCM in the results table, then the steps: the Euclidean divisions that produce the GCD, the fold that builds the LCM one number at a time, and the prime factorizations with the smallest and largest exponents picked out.
- For a list, the answers fold pairwise: gcd(gcd(a, b), c) and lcm(lcm(a, b), c). The steps show each fold, so a long list is as checkable as a pair.
The method
The Euclidean algorithm
The algorithm works because any common divisor of a and b also divides their remainder, so the pair shrinks without the answer changing. It is fast even for large numbers, which is why it, rather than listing factors, is the method used here, and its steps are the ones printed.
The LCM from the GCD
lcm(a, b) = |a × b| / gcd(a, b). Whatever the two numbers share is counted twice in their product, and dividing by the GCD removes the duplicate. For a list, the formula folds: each new number is combined with the running LCM the same way. All of it is exact whole-number arithmetic, so large LCMs print in full rather than in scientific notation.
Prime factorizations, as the check
Factor each number into primes: 12 = 2² · 3 and 18 = 2 · 3². The GCD takes the smaller exponent of each prime (2¹ · 3¹ = 6) and the LCM takes the larger (2² · 3² = 36). Both factorizations and both exponent picks are shown, so the Euclidean answer and the prime answer stand side by side; they must agree, and on this page they are both computed, not copied from each other.
Zeros and signs, by convention
gcd(0, n) = |n|, because every number divides 0 and the largest divisor of n is itself the largest common one. gcd(0, 0) is undefined, since every number divides both, so there is no greatest; the tool refuses it. lcm(0, n) = 0 for any n, because 0 is the only common multiple of 0 with anything. Signs are ignored: gcd(−12, 18) = 6.
Worked examples
Example 1: the preloaded pair
12 and 18: factorizations 2² · 3 and 2 · 3², so GCD = 6 and LCM = 36. The identity checks: 6 × 36 = 216 = 12 × 18.
Example 2: a list of three
8, 12 and 20: gcd(8, 12) = 4 and gcd(4, 20) = 4, so GCD = 4; lcm(8, 12) = 24 and lcm(24, 20) = 120, so LCM = 120. Folding is all a list ever needs.
Example 3: coprime numbers
7 and 13 share no prime factors, so GCD = 1 (the pair is called coprime) and the LCM is simply their product, 91. A GCD of 1 is also what a fraction like 13/7 needs to be already in lowest terms.
Example 4: a larger pair
100 and 75: 100 = 2² · 5² and 75 = 3 · 5², so GCD = 25 and LCM = 300, and 25 × 300 = 7,500 = 100 × 75 as required.
Example 5: zero, used honestly
0 and 6: GCD = 6 by the convention above, and LCM = 0, because no positive multiple of 0 exists. Contrast 0 and 0, which the tool refuses: a greatest common divisor cannot be picked when every number qualifies.
Reading your results
The GCD is about sharing and simplifying. It is the largest equal size both numbers split into (12 and 18 both split into 6s), the divisor that reduces a ratio or fraction to lowest terms, and the test for whether two numbers are coprime.
The LCM is about syncing and combining. It is the smallest quantity both numbers divide into: the least common denominator for adding fractions with denominators 12 and 18 (36), and the first moment two cycles of lengths 12 and 18 realign.
The identity is a two-number fact. GCD × LCM = a × b holds for pairs because the shared part is counted exactly twice. It does not extend to lists of three or more, which is why the check line appears only for pairs.
Common mistakes
- Reaching for the LCM when the GCD is wanted, and back. Simplifying needs the GCD (divide both by it); common denominators need the LCM. If the answer should be smaller than both numbers it is a GCD shape; if larger than both, an LCM shape.
- Trying gcd(0, 0). There is no greatest common divisor of nothing and nothing; every integer divides 0. gcd(0, n) is |n|, and that is the only zero case with an answer.
- Feeding decimals directly. GCD and LCM are defined for integers. 0.12 and 0.18 have no GCD until scaled by 100 into 12 and 18 (GCD 6, meaning 0.06 before scaling back), which is the honest way to handle decimal data.
- Worrying about the sign. A greatest common divisor is reported positive by convention; −12 and 18 have GCD 6 exactly as 12 and 18 do. The tool ignores signs and says so.
- Believing the LCM of a list is the product divided by the GCD of the list. That identity is for two numbers only. Lists fold pairwise, and shortcuts here produce plausible-looking wrong answers; the fold steps on this page show the real route.
- Expecting variables. The greatest common factor of algebraic expressions (say 6x² and 9x) needs factoring of terms and variables, which is the factoring calculator’s territory; this page is for integers.
Limitations
- Integers only: decimals, fractions and expressions are refused with the reason named, rather than silently rounded. Scale decimals to integers first if a GCD of decimal data is genuinely needed.
- Each number is capped at 999,999,999,999 so the prime factorization stays instant by trial division; the GCD and LCM themselves would scale much further, but the factorization display is part of this page’s method and the cap keeps it honest.
- Between 2 and 12 numbers per calculation. Longer lists fold the same way in batches.
- Fraction operations themselves (adding with the common denominator, simplifying with the GCD) live on the fraction calculator; this page supplies the two numbers those operations need.
Frequently asked questions
Are GCF and GCD the same thing?
Yes: greatest common factor and greatest common divisor name the same number. “Factor” is the school term, “divisor” the number-theory term. This page uses GCD in the workings and answers both searches because the mathematics is identical.
Why is gcd(0, 5) equal to 5 but gcd(0, 0) undefined?
Every integer divides 0, so the common divisors of 0 and 5 are exactly the divisors of 5, whose greatest is 5. For 0 and 0 the common divisors are all integers without exception, so there is no greatest one to name. The asymmetry is real mathematics, not a quirk of this tool.
Why is the LCM of 0 and anything equal to 0?
A common multiple of 0 and n must be a multiple of 0, and the only multiple of 0 is 0 itself (0 × k = 0). So 0 is the least, and only, common multiple. In list calculations a single zero therefore makes the LCM 0, which the steps state openly.
Does GCD × LCM always equal the product of the numbers?
For two numbers, yes: a × b = gcd(a, b) × lcm(a, b), because the prime exponents split into a smaller and a larger pick whose sum is the two original exponents. For three or more numbers the identity fails, which is why lists are folded pairwise here and no such check is claimed for them.
What does it mean when the GCD is 1?
The numbers are coprime (relatively prime): they share no prime factor. Consequences: their LCM is their product, a fraction with them as numerator and denominator is already in lowest terms, and they generate each other’s cycles completely, which is why gear teeth are often chosen coprime.
How does the LCM become a common denominator?
To add fractions, each denominator must divide the shared one, and the smallest such is the LCM of the denominators: for twelfths and eighteenths it is 36. Any common multiple works arithmetically, but the LCM keeps the numbers smallest and the final simplification lightest.
Related calculators
- Math calculators
- Fraction Calculator: uses the GCD to simplify and the LCM as the common denominator.
- Ratio and Proportion Calculator: simplifying a ratio is this page’s GCD applied to a pair.
Method: the GCD is computed by the Euclidean algorithm (repeated remainder steps, printed in full for each pairwise fold) and the LCM by lcm(a, b) = |a · b| / gcd(a, b), folded across the list, all in exact whole-number arithmetic. Prime factorizations by trial division are shown for every non-zero entry, and the GCD and LCM are independently rebuilt from the smallest and largest exponents as a check. Conventions: gcd(0, n) = |n|, gcd(0, 0) refused as undefined, lcm(0, n) = 0, signs ignored. Last reviewed: 21 October 2026.
Disclaimer: This calculator gives estimates for general information only. It is not financial, medical or other professional advice.
