Easy CalculatorsOnline
A little less guesswork.

Math · EVERYDAY CLARITY

GCD & LCM calculator

Find the greatest common divisor and least common multiple.

Units & number format

Number formatting changes the display; the interface and guides are in English. Dates use calendar controls; numeric lists use decimal points and comma or space separators.

01 · CALCULATE

Work out your numbers

Your inputs stay in this browser.

Example result · using the values shown

Greatest common divisor
6
Least common multiple36
See visual ↓

Nonnegative integers. GCD(0,0) is reported as 0; LCM is 0 when either input is 0.

02 · SEE THE RESULT

Your numbers, pictured

Example visualization

The relationship between GCD and LCM

GCD 6×LCM 36
Calculated result216

For nonnegative integers, GCD × LCM equals the product of the two numbers.

03 · UNDERSTAND THE METHOD

How the gcd & lcm calculator works

The greatest common divisor, or GCD, is the largest positive integer that divides both input integers without a remainder. The least common multiple, or LCM, is the smallest positive multiple shared by two nonzero integer magnitudes. This calculator provides both results because they answer related but different questions. GCD helps reduce fractions or group objects evenly; LCM helps align repeating cycles or find a common denominator.

The formula and its variables

g = gcd(|a|, |b|); lcm(a,b) = |(a/g) × b| for nonzero inputs
a, b
Integer inputs.
g
Greatest common divisor of the input magnitudes.
LCM
Least common multiple, conventionally zero when one input is zero.

The calculation, step by step

  1. Enter two whole-number integers within the accepted range. The calculation uses absolute magnitudes when finding positive factors and multiples.
  2. Use Euclid’s algorithm: replace a pair with the second number and the remainder until the remainder is zero. The last nonzero value is the GCD.
  3. Divide one input by the GCD before multiplying by the other to obtain the LCM. Handle a zero input separately rather than dividing by zero.

A worked example

For 12 and 18, common divisors are 1, 2, 3, and 6, so GCD is 6. The LCM is (12 ÷ 6) × 18 = 36. Two cycles lasting 12 and 18 time units align every 36 units when they start together. A fraction 12/18 reduces by the GCD to 2/3.

Example inputs and calculated output
First integer12
Second integer18
Greatest common divisor6

How to read the result and visual

The divisor describes the largest equal grouping possible for both numbers. The multiple describes the earliest shared repetition under integer cycles. When numbers have no shared factor besides one, the GCD is one and their LCM is the product of their magnitudes. Equal positive inputs produce the same value for both results.

Assumptions, rounding, and limitations

These operations use integers, not fractional measurement durations or arbitrary real numbers. Decimal inputs should be scaled deliberately into integers before use. Very large LCM products can exceed exact browser integer precision and are constrained by validation. A zero pair is handled by explicit conventions rather than by claiming a largest positive divisor of both zeros.

Frequently asked questions

Can I enter negative integers?

This tool accepts nonnegative integers. For a negative integer, enter its absolute magnitude to obtain the positive GCD and LCM.

Why is LCM useful for fractions?

A common denominator must be a multiple of each denominator; the least common multiple provides the smallest positive choice.

Reference sources

How we check calculations and what verification covers