LCM and GCF Calculator: Least Common Multiple

LCM and GCF Calculator
LEAST COMMON MULTIPLE
–
GREATEST COMMON FACTOR
–
COPRIME?
–
PRIME FACTORS OF FIRST
–
PRIME FACTORS OF SECOND
–
LCM(a,b) × GCF(a,b) always equals a × b: a handy cross-check.

The least common multiple and greatest common factor are two sides of the same coin: both describe how two numbers fit together. Enter any two positive whole numbers above and the calculator returns the LCM, the GCF, whether the numbers are coprime, and the prime factorization of each, all computed instantly with the Euclidean algorithm.

What LCM and GCF mean

The greatest common factor (GCF) is the largest number that divides both numbers evenly. The least common multiple (LCM) is the smallest number that both numbers divide into evenly. They are linked by one elegant identity:

LCM(a, b) = |a × b| ÷ GCF(a, b)
The GCF itself comes from the Euclidean algorithm: repeatedly replace (a, b) with (b, a mod b) until the remainder is zero. The last nonzero remainder is the GCF.

Example with 12 and 18: Euclid gives GCF(12, 18) = 6 (since 18 mod 12 = 6, and 12 mod 6 = 0). Then LCM = (12 × 18) ÷ 6 = 216 ÷ 6 = 36. You can sanity-check any result with the identity above: LCM × GCF always equals a × b.

Worked example: 12 and 18

StepResult
Prime factors of 122² × 3
Prime factors of 182 × 3²
GCF (shared primes, lowest powers)2 × 3 = 6
LCM (all primes, highest powers)2² × 3² = 36

The prime-factor view shows why it works: the GCF takes each shared prime at its lowest power, the LCM takes every prime at its highest power. Multiply them and each prime's powers add up exactly to the powers in a × b.

When to use LCM vs GCF

Use the LCM when you need a common cycle or denominator: adding fractions (the least common denominator is just the LCM of the denominators), scheduling repeating events (two buses on 12- and 18-minute loops meet every 36 minutes), or syncing gear rotations. Use the GCF when splitting things into the largest equal groups: dividing 12 apples and 18 oranges into identical bags gives 6 bags of 2 apples and 3 oranges, and simplifying the fraction 12/18 to 2/3.

Coprime numbers

When the GCF is 1, the numbers are coprime (also called relatively prime): they share no prime factors at all. For coprime numbers the LCM is simply their product, which is why the calculator shows 91 for 7 and 13. Coprimality matters in surprising places: the RSA encryption protecting your web traffic relies on arithmetic with huge coprime numbers.

What this calculator doesn't include

The tool works with pairs of positive whole numbers up to 1,000,000,000. It does not handle decimals, negative numbers, or zero (the LCM of zero is undefined in the usual sense), and it computes one pair at a time. For three or more numbers, chain the results: LCM(a, b, c) = LCM(LCM(a, b), c), and the same chaining works for the GCF.

Frequently asked questions

What is the difference between LCM and GCF?

The GCF is the biggest number that divides both numbers; the LCM is the smallest number both numbers divide into. For 12 and 18, the GCF is 6 and the LCM is 36.

How do you find the LCM of three numbers?

Chain them: first find LCM(a, b), then find the LCM of that result with c. For example, LCM(4, 6, 8) = LCM(12, 8) = 24.

If one number divides the other, what are the LCM and GCF?

The GCF is the smaller number and the LCM is the larger one. For 5 and 15: GCF = 5, LCM = 15.

Why does the Euclidean algorithm work?

Any common divisor of a and b also divides the remainder a mod b, so the set of common divisors never changes as you shrink the pair. When the remainder hits zero, the other number is the greatest common divisor.

What is the LCM of 0 and another number?

Every number divides 0, so there is no smallest positive common multiple in the usual sense; the LCM with 0 is conventionally 0. This calculator accepts positive whole numbers only.

Is 1 coprime with every number?

Yes. The only divisor of 1 is 1 itself, so GCF(1, n) = 1 for any n, and LCM(1, n) = n.

References

Definitions and algorithms: Least common multiple — Wikipedia; Greatest common divisor — Wikipedia.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top