Mathematics & StatisticsLast updated: 2026-09-30

GCD & LCM Calculator

Compute the greatest common divisor (GCD) and least common multiple (LCM) of two or three positive integers with exact BigInt arithmetic and the Euclidean algorithm working shown.

Client-Side · Zero TelemetryPrivate & Secure
GCD・LCM

Try an example

Enter two or more positive integers to see the GCD and LCM.

ShareXfB!L

How to use

  1. 1

    Enter the numbers

    Type two or three positive integers. C is optional.

  2. 2

    Read GCD and LCM

    The greatest common divisor and least common multiple are shown.

  3. 3

    Read the working

    The Euclidean algorithm steps and the LCM = A × B ÷ GCD calculation are displayed.

Features

  • GCD and LCM of two or three integers with exact BigInt arithmetic (up to 10¹²)
  • Euclidean algorithm steps shown as substituted working
  • The LCM = A × B ÷ GCD relation displayed alongside
  • Coprime detection (GCD = 1) at a glance; inputs are never transmitted

Use cases

Check divisors homework

Verify hand-worked GCD and LCM problems against the Euclidean steps.

Fraction arithmetic

Find the LCM of denominators for common denominators, and the GCD for reducing.

Verify program output

Compare your gcd/lcm function results against exact big-integer values.

Details

The greatest common divisor (GCD) is the largest integer that divides two or more numbers, computed efficiently by the Euclidean algorithm. The least common multiple (LCM) is the smallest multiple they share, given by LCM = A × B ÷ GCD. The tool computes both exactly with BigInt (arbitrary-precision integers).

Three numbers are supported: the GCD composes pairwise (gcd(a, b, c) = gcd(gcd(a, b), c)), and the LCM composes pairwise as well. Inputs accept positive integers up to one trillion (10¹²), and results never overflow.

Conditions: all inputs must be positive integers (zero, negatives and decimals are not supported). Two coprime numbers (e.g. 7 and 13) give GCD = 1 and LCM = A × B. Inputs are never transmitted; all computation happens locally in your browser.

FAQ

What is the GCD?

The greatest common divisor is the largest integer that divides all the given numbers. For 12 and 18 the GCD is 6. The Euclidean algorithm finds it efficiently even for large numbers.

How do I find the LCM?

Use LCM = A × B ÷ GCD. For 12 and 18: 12 × 18 ÷ 6 = 36. For three or more numbers, compose pairwise: LCM(LCM(a, b), c).

What does coprime mean?

Two integers are coprime when their GCD is 1 — they share no common divisor other than 1. In that case the LCM is simply A × B.

Can I compute for three numbers?

Yes, up to three. The GCD composes pairwise as gcd(gcd(a, b), c), and the LCM likewise. Use the optional C field for the third number.

All processing happens in your browser. Your files are never uploaded.

Verified: Known values (gcd(12,18)=6, lcm=36, three numbers → 12/360, coprime → 1), zero/negative/decimal/range errors, BigInt large numbers and the English page are covered by browser tests

Did you know?

The identity gcd(A, B) × lcm(A, B) = A × B always holds: for 12 and 18, 6 × 36 = 216 = 12 × 18. GCD and LCM are two faces of the same coin — knowing one instantly gives the other.

Optional usage measurement settings

Only with your consent, a random browser ID and tool/learning events are sent to measure return visits. This is pseudonymous measurement. Inputs, answers, keys, files and search terms are excluded. Consent expires after 90 days. Declining does not limit any feature.

Measurement is off.

Retention and privacy