# GCF and LCM Calculator

The greatest common factor (GCF, also called GCD or HCF) is the largest number that divides every number in the list, and the least common multiple (LCM) is the smallest positive number they all divide. For 84, 126, 210: GCF = 42 and LCM = 1260. For two numbers such as 48 and 180, GCF = 12 and LCM = 720, and the two always satisfy GCF × LCM = 48 × 180 = 8640. The calculator takes 2 to 20 whole numbers of up to 30 digits (negatives and 0 are handled by the usual conventions), shows Euclid’s algorithm step by step, the prime-factor method and, for small inputs, a list of multiples, and also simplifies a fraction with its GCF and finds Bézout coefficients.

Canonical page: https://ponderloop.com/tools/gcf-lcm-calculator/
Updated: 2026-10-18

## How to use

How to find the GCF and LCM

1. **Use Euclid’s algorithm for the GCF**: Divide the larger number by the smaller and keep the remainder; repeat with the smaller number and the remainder until it is 0. For 240 and 46: 240 = 5 × 46 + 10, then 46 = 4 × 10 + 6, then 10 = 1 × 6 + 4, then 6 = 1 × 4 + 2, then 4 = 2 × 2 + 0. The last non-zero remainder, 2, is the GCF.
2. **Or compare prime factors**: Factor each number into primes. Multiply the primes common to all, each to its lowest power: 2 × 3 = 6. Multiply every prime that appears, each to its highest power: 2² × 3² = 36. For 12 and 18 that gives GCF 6 and LCM 36.
3. **Get the LCM from the GCF**: For two numbers, LCM = |a × b| ÷ GCF. For 48 and 180: 48 × 180 ÷ 12 = 720. For more numbers, fold left: LCM(6, 4, 10) = LCM(LCM(6, 4), 10) = LCM(12, 10) = 60.
4. **Or list multiples for small numbers**: Write multiples of each number until one appears in every list. For 4 and 6 the lists 4, 8, 12 and 6, 12 meet at 12.
5. **Simplify a fraction with the GCF**: Divide the numerator and denominator by their GCF: the GCF of 18 and 24 is 6, so 18/24 = 3/4.

## Reference tables and worked examples

### Worked examples

Each row is computed by the calculator above. The last column checks that GCF × LCM equals the product of the two numbers.

| Numbers | GCF | LCM | GCF × LCM = a × b |
| --- | --- | --- | --- |
| 12, 18 | 6 | 36 | 6 × 36 = 216 |
| 8, 12 | 4 | 24 | 4 × 24 = 96 |
| 48, 180 | 12 | 720 | 12 × 720 = 8640 |
| 21, 6 | 3 | 42 | 3 × 42 = 126 |
| 35, 64 | 1 | 2240 | 1 × 2240 = 2240 |
| 84, 126 | 42 | 252 | 42 × 252 = 10584 |
| 100, 75 | 25 | 300 | 25 × 300 = 7500 |
| 1071, 462 | 21 | 23562 | 21 × 23562 = 494802 |

### Zero, negatives and other edge cases

Signs are ignored and the results are never negative. The GCF of 0 and 0 is a convention: some texts leave it undefined, and this calculator reports 0.

| Numbers | GCF | LCM | Why |
| --- | --- | --- | --- |
| 12, 0 | 12 | 0 | Every number divides 0, so GCF(0, n) = \|n\|; the only common multiple is 0 |
| 0, 0 | 0 | 0 | Every number divides 0, so there is no greatest divisor; reported as 0 |
| −12, 18 | 6 | 36 | Signs are dropped first |
| −12, −18 | 6 | 36 | Signs are dropped first |
| 1, 7 | 1 | 7 | Coprime numbers share only the factor 1, so the LCM is their product |
| 7, 7 | 7 | 7 | A number is its own GCF and LCM |

### Euclid’s algorithm for 240 and 46, with Bézout coefficients

Each row is a = q × b + r, then the pair (b, r) repeats. The extended algorithm tracks coefficients so that 240 × s + 46 × t = r on every row; the last non-zero row gives −9 and 47.

| q | r | s | t |
| --- | --- | --- | --- |
| – | 240 | 1 | 0 |
| – | 46 | 0 | 1 |
| 5 | 10 | 1 | −5 |
| 4 | 6 | −4 | 21 |
| 1 | 4 | 5 | −26 |
| 1 | 2 | −9 | 47 |
| 2 | 0 | 23 | −120 |

## How it works

Every number is read as an exact integer (BigInt), so nothing is rounded. Signs are dropped: GCF(a, b) = GCF(|a|, |b|), with GCF(0, n) = |n| and GCF(0, 0) = 0 by convention, and the LCM is |a × b| ÷ GCF(a, b), or 0 when either number is 0. A list is combined from the left: GCF(a, b, c) = GCF(GCF(a, b), c), and the same for the LCM. Euclid’s algorithm repeats a = q × b + r on the larger and smaller number until the remainder is 0, as described in Knuth’s The Art of Computer Programming, volume 2, section 4.5.2. The extended algorithm carries two extra columns, s and t, through the same divisions so that every remainder equals a × s + b × t. The prime-factor method divides out 2 and then odd candidates up to the square root, using a small factorizer written for this page; then the GCF takes each shared prime at its lowest power and the LCM takes every prime at its highest. The multiples method lists the multiples of each number up to the LCM. Fractions are reduced by dividing top and bottom by their GCF, with the sign kept on the top. Everything runs in your browser and nothing you type is sent anywhere.

## FAQ

### What is the difference between GCF, GCD and HCF?

Nothing: greatest common factor (GCF), greatest common divisor (GCD) and highest common factor (HCF) are three names for the same number, the largest whole number that divides every number given. The GCF of 48 and 180 is 12.

### How do you find the LCM of two numbers?

Divide the product by the GCF: LCM(a, b) = |a × b| ÷ GCF(a, b). For 48 and 180 that is 8640 ÷ 12 = 720. You can also list multiples of each number until one appears in both lists, or take every prime at its highest power.

### How do you find the GCF and LCM of three or more numbers?

Combine them one at a time, because GCF(a, b, c) = GCF(GCF(a, b), c) and the same holds for the LCM. For 84, 126, 210 the GCF is 42 and the LCM is 1260. Note that GCF × LCM = product holds for exactly two numbers, not for three or more.

### How does Euclid’s algorithm work?

It rests on GCF(a, b) = GCF(b, a mod b). Repeat the division a = q × b + r until the remainder is 0; the last non-zero remainder is the GCF. For 240 and 46 it takes 5 divisions to reach 2. It needs far fewer steps than factoring, and it works on numbers far too big to factor.

### What are Bézout coefficients?

They are whole numbers x and y with a × x + b × y = GCF(a, b). The extended Euclidean algorithm finds them by tracking the coefficients through each division. For 240 and 46: 240 × −9 + 46 × 47 = 2. They are not unique: adding k × b/GCF to x and subtracting k × a/GCF from y gives another pair. When the GCF is 1, x is the modular inverse of a modulo b (up to adding b).

### What is the GCF or LCM when one number is 0?

Every number divides 0, so GCF(0, n) = |n|; for example GCF(0, 12) = 12. The only common multiple of 0 and anything is 0, so the LCM is 0. GCF(0, 0) has no greatest divisor, since every number divides 0. Some texts call it undefined and many programming libraries return 0, which is what this calculator reports (0).

### Can the GCF or LCM be negative?

By the usual convention no: the GCF and LCM are taken on absolute values and are never negative. GCF(−12, 18) = 6 and LCM(−12, 18) = 36. Bézout coefficients keep the signs of the inputs, so a × x + b × y still equals the GCF.

### What if the GCF is 1?

Then the numbers are coprime (relatively prime): they share no factor above 1, and for two numbers the LCM is their product. GCF(8, 15) = 1 and LCM(8, 15) = 120. A fraction whose numerator and denominator are coprime is already in lowest terms.

### How do you simplify a fraction with the GCF?

Divide both the numerator and the denominator by their GCF. For 18/24 the GCF is 6, so 18/24 = 3/4. A negative denominator is moved to the numerator, so 3/−6 = −1/2. To add or compare fractions, use the fraction calculator.

### How big can the numbers be?

Each number can have up to 30 digits, because the calculator uses exact arbitrary-size integers (BigInt) and never rounds. The prime-factor method uses trial division, so it is shown only for numbers up to 1,000,000,000,000; the multiples method only while the LCM is 200 or less. Euclid’s algorithm and the extended algorithm work at any size here.

## Sources

- Donald E. Knuth, The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, §4.5.2 “The Greatest Common Divisor” (Addison-Wesley)
- [Greatest Common Divisor, Wolfram MathWorld](https://mathworld.wolfram.com/GreatestCommonDivisor.html)
- [Least Common Multiple, Wolfram MathWorld](https://mathworld.wolfram.com/LeastCommonMultiple.html)
- [Euclidean Algorithm, Wolfram MathWorld](https://mathworld.wolfram.com/EuclideanAlgorithm.html)

---

Cite as: GCF and LCM Calculator, ponderloop, https://ponderloop.com/tools/gcf-lcm-calculator/, updated 2026-10-18
