LCM and GCD Calculator

MATH FREE

Free LCM and GCD calculator. Find the least common multiple and greatest common divisor of two or three numbers instantly.

GCD and LCM of two or three numbers

A GCD and LCM calculator returns two linked facts about a set of integers: the greatest common divisor, the largest number that divides every input exactly, and the least common multiple, the smallest number that every input divides into exactly. Enter 12 and 18 and you get a GCD of 6 and an LCM of 36.

How the calculation works

The GCD comes from Euclid’s algorithm. It divides the larger number by the smaller, replaces the pair with the smaller number and the remainder, and repeats until the remainder is zero. The last non-zero remainder is the GCD. Watch it run on 12 and 18:

  • 18 mod 12 = 6
  • 12 mod 6 = 0
  • The GCD is the last divisor, 6.

The LCM uses the identity LCM = |a × b| ÷ GCD. For a third number the tool folds the operation across the set: it computes the GCD pair by pair and the LCM pair by pair. Leave the optional third field at zero to work with two numbers, and remember that all inputs are treated as positive whole numbers.

Worked example with the default values

The form loads 12 and 18, with the third field at 0, so two numbers are processed.

QuantityWorkingResult
GCDEuclid on 12 and 186
LCM12 × 18 ÷ 6 = 216 ÷ 636
Check6 × 36 = 216 = 12 × 18holds

Adding a third value of 30 gives a GCD of 6 and an LCM of 180. Verify the LCM by division: 180 ÷ 12 = 15, 180 ÷ 18 = 10, and 180 ÷ 30 = 6. The identity GCD × LCM = a × b holds for two numbers only, so do not apply it to three.

Reference: common pairs

NumbersGCDLCMNote
12, 18636Shared factor 6
8, 12424Shared factor 4
7, 5135Coprime, so LCM is the product
24, 36127236 is a factor relationship
9, 15345Shared factor 3
10, 15, 20560Three inputs

When two numbers are coprime their GCD is 1 and their LCM is simply their product, which is why 5 and 7 give an LCM of 35.

Common mistakes

  • Confusing the two outputs. The GCD of 12 and 18 is 6, the largest shared factor; the LCM is 36, the smallest shared multiple.
  • Typing 0 into the optional field. Zero means “use two numbers”, not “include zero”; leave the field blank or at 0.
  • Assuming the LCM is the product. That is true only for coprime numbers. For 12 and 18 the product 216 is not the LCM.
  • Using non-integer inputs. The tool parses whole numbers; decimals are truncated, so the result may not match a hand calculation.

How do I add fractions without a common denominator?

Use the LCM as the common denominator. To add 1/12 and 1/18, the LCM of 12 and 18 is 36, so rewrite them as 3/36 and 2/36 and add to get 5/36. The LCM is exactly the lowest common denominator a textbook asks for.

How do I reduce a fraction to lowest terms?

Divide the numerator and denominator by their GCD. For 12/18 the GCD is 6, giving 2/3. The GCD is always the single largest number you can cancel in one step.

When do two repeating events line up again?

At their LCM. If one event repeats every 12 days and another every 18 days, they next coincide after 36 days. This is the classic word-problem use of the LCM, and it works the same for flashing lights, bus timetables, and gear teeth.

Does a negative sign change the answer?

No. Both operations use absolute values, so −12 and 12 have the same GCD and LCM with any other input. The tool only accepts positive values in its number fields, which avoids the issue entirely.

For the arithmetic side of fraction work, the basic calculator is a quick check, and the ratio calculator applies the same divisibility ideas to scaling proportions.