Calcufast

LCM and GCD Calculator with Steps

Find the least common multiple and greatest common divisor of 2 to 10 positive integers. Follow each step of the Euclidean algorithm.

Inputs
Enter values to calculate

Enter 2 to 10 numbers, each from 1 to 1000000000. Separate them with commas, spaces or semicolons; do not use thousands separators.

Try an example:

Step-by-step calculation

Euclid repeats division until the remainder is zero. The last nonzero divisor is the GCD. For the LCM: divide the accumulated multiple by its GCD with the next number, then multiply by that number.

  1. Step 1

    GCD(12, 18) = 6

    • 12 = 18 × 0 + 12
    • 18 = 12 × 1 + 6
    • 12 = 6 × 2 + 0

    GCD(12, 18) = 6

    LCM(12, 18) = 12 ÷ 6 × 18 = 36

Advertisement
Results

Least common multiple (LCM)

36

Greatest common divisor (GCD)

6

Exact integer results, without rounding.

LCM and GCD answer different questions

The least common multiple (LCM) helps find a common denominator for fractions or when cycles starting together coincide. The greatest common divisor (GCD) helps simplify a fraction or divide quantities into equal groups without leftovers. This tool works with positive integers only.

Step-by-step example

For 12 and 18, Euclid gives:

12 = 18 × 0 + 12
18 = 12 × 1 + 6
12 = 6 × 2 + 0

The last nonzero divisor is 6, so GCD = 6. Then LCM = 12 ÷ 6 × 18 = 36. Check: 36 ÷ 12 = 3 and 36 ÷ 18 = 2.

Three numbers: 8, 12 and 20

First LCM(8, 12) = 24 and GCD(8, 12) = 4. Then GCD(24, 20) = 4, so LCM(24, 20) = 24 ÷ 4 × 20 = 120. Separately, GCD(4, 20) = 4. Do not use the accumulated GCD as the LCM divisor without recomputing the GCD of the relevant pair.

Entering your numbers

Use commas, spaces or semicolons: 8, 12, 20, 8 12 20 and 8;12;20 are equivalent. A comma separates two numbers; it is not a decimal separator. Do not enter thousands separators: write 1000, not 1,000. Enter 2 to 10 values from 1 to 1000000000.

Repeated numbers are valid: 12 and 12 give LCM = 12 and GCD = 12. For 7 and 11, which share no factor greater than 1, GCD = 1 and LCM = 77. If one of the numbers is 1, the GCD is 1.

Precision and limits

Results use arbitrary-precision integers, even when the LCM exceeds the exact-integer range of JavaScript Number. There is no decimal approximation. This tool excludes zeros, negatives and fractions to use one positive definition; it does not imply that other mathematical conventions do not exist.

Sources and related tools

The Euclidean algorithm and least common multiple identity, documented by Wolfram MathWorld, support the steps shown.

For proportions, use the rule of three calculator; for percentages, use the percentage calculator.

Frequently asked questions

The LCM is the smallest positive integer divisible by all the given numbers. The GCD is the largest positive integer that divides them all. For 12 and 18, the LCM is 36 and the GCD is 6.

For two positive integers, LCM(a, b) = a ÷ GCD(a, b) × b. For 12 and 18: 12 ÷ 6 × 18 = 36. With more numbers, repeat using the accumulated LCM.

Yes, you can enter 2 to 10 positive integers. For example, for 8, 12 and 20, the LCM is 120 and the GCD is 4.

This tool accepts only positive integers from 1 to 1000000000. Use commas, spaces or semicolons to separate numbers, not to indicate decimals or thousands.