Zero Signup ToolsFree browser tools

Calculator Tools

GCD and LCM Calculator

Find the greatest common divisor (GCD/HCF) and least common multiple (LCM) of two or more numbers, with Euclidean algorithm steps and prime factorization.

Numbers to compare

Enter two or more positive whole numbers, up to 18 digits each. Underscores, spaces, and commas inside numbers are ignored.

Try:

GCD

Greatest common divisor (HCF) of 2 numbers.

6

Every input is exactly divisible by 6, and no larger number divides them all.

LCM

Least common multiple of 2 numbers.

36

The smallest positive integer that every input divides into without a remainder.

Identity check

gcd(12, 18) * lcm(12, 18) = 216

12 * 18 = 216

For any two positive integers, gcd(a, b) times lcm(a, b) always equals a times b.

Euclidean algorithm

Step-by-step trace of gcd(12, 18).

  1. Step 118 = 12 * 1 + 6
  2. Step 212 = 6 * 2 + 0

The algorithm divides the larger number by the smaller, then replaces the pair with (divisor, remainder) and repeats. When the remainder reaches zero, the divisor is the GCD.

Prime factorization method

Break each number into prime factors. The GCD multiplies the shared primes raised to the smallest exponent. The LCM multiplies every prime raised to the largest exponent.

12

12 = 2^2 * 3

18

18 = 2 * 3^2

PrimeMin exponent (GCD)Max exponent (LCM)
212
312

GCD as prime product

6 = 2 * 3

LCM as prime product

36 = 2^2 * 3^2

Divisors of the GCD

Every common divisor of the inputs is a divisor of the GCD.

  • 1
  • 2
  • 3
  • 6

First multiples of the LCM

Every common multiple of the inputs is a multiple of the LCM.

  • 1x 36
  • 2x 72
  • 3x 108
  • 4x 144
  • 5x 180
  • 6x 216
  • 7x 252
  • 8x 288

Full result as plain text

Includes both answers, the Euclidean trace, the identity check, and the factorizations.

What the GCD and LCM mean

  • The greatest common divisor (GCD) of a set of positive integers is the largest number that divides every input with no remainder. It is also called the highest common factor (HCF) or greatest common factor (GCF).
  • The least common multiple (LCM) is the smallest positive integer that every input divides into evenly.
  • For exactly two numbers, gcd(a, b) times lcm(a, b) always equals a times b. The identity check above uses this to verify the result.
  • When the GCD equals 1, the numbers are coprime: they share no prime factors. Many fraction-simplification problems boil down to dividing both numerator and denominator by the GCD.

How the result is computed

  • The GCD uses the Euclidean algorithm, which replaces the pair (a, b) with (b, a mod b) until one side reaches zero. For more than two inputs the algorithm is applied pairwise.
  • The prime factorization view splits every input into prime powers, then reads the GCD as the minimum exponent for each shared prime and the LCM as the maximum exponent for every prime that appears anywhere.
  • All math runs with JavaScript BigInt, so numbers up to 18 digits keep full precision. Nothing you type is uploaded; the calculation happens entirely in your browser.

How to use

  1. Enter at least two positive whole numbers into the input fields. Click Add number to compare more than two; the calculator handles up to twelve at once. Underscores, spaces, and commas inside numbers are ignored, so 1_000_000 and 1,000,000 both work.
  2. Read the GCD and LCM cards at the top. The GCD card highlights when the inputs are coprime (GCD equals 1) and the LCM card always shows the smallest positive number every input divides into.
  3. Open the Euclidean algorithm panel to see the gcd(a, b) trace as a sequence of long-division lines, then copy the steps if you need to paste them into homework or a write-up.
  4. Scroll to Prime factorization method to see each number broken into prime powers, the min/max exponent table, and the GCD and LCM written out as prime products.
  5. Use the divisors of the GCD and the first multiples of the LCM panels to answer related questions: every common divisor is in the first list and every common multiple is a multiple of the LCM. Click Copy full result to grab everything as plain text.

About this tool

GCD and LCM Calculator finds the greatest common divisor and the least common multiple of any two or more positive integers, and shows the working in three ways at once. It runs the Euclidean algorithm and prints every long-division step (a = b * q + r) so you can copy the trace into a homework write-up or a code review. It builds the prime factorization of each input and lines up the shared primes in a table, with the minimum exponent column reading off as the GCD and the maximum exponent column reading off as the LCM, which is the textbook method most teachers expect to see. It also lists every divisor of the GCD and the first several multiples of the LCM, and for two-number inputs it verifies the identity gcd(a, b) times lcm(a, b) equals a times b. All math runs locally with JavaScript BigInt, so numbers of up to eighteen digits keep full precision and nothing you type is uploaded. The same machinery powers fraction simplification (divide the numerator and denominator by their GCD), common-denominator addition (use the LCM of the denominators), gear ratio and pulley sync problems, scheduling problems (when do two repeating events line up again?), tile and brick layout, and number-theory practice. Try the presets to see edge cases: coprime triples like 8, 9, 25 where the GCD collapses to 1; sets where one number divides the rest so the GCD equals the smallest input; and the classic fraction-denominator pair (6 and 8) that produces the smallest common denominator (24).

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsCalculator Tools