Calculators & Converters

GCD and LCM Calculator

Calculate a common divisor and a common multiple for an entire list of integers. Large inputs remain exact, and the accumulation trace shows how each additional value changes the running GCD and LCM.

Free online tool

Loading tool…

Enter 2–30 integers, separated by spaces, commas, or new lines. Up to 100 digits each. Signs are ignored for GCD and LCM; a zero input makes LCM zero.

Calculations run locally in your browser. This tool does not upload the numbers you enter.

GET STARTED

How to use the GCD and LCM Calculator

  1. 01

    Enter 2–30 integers separated by spaces, commas, semicolons, or new lines.

  2. 02

    Calculate to see the nonnegative GCD and LCM and a trace after each input.

  3. 03

    Review zero and sign conventions before copying or downloading the exact text output.

Examples

A shared unit

For 48, 180, and 240, the GCD is 12 and the LCM is 720. All three values are divisible by 12, and each divides 720.

Signs and zero

For −18 and 24, the result is GCD 6 and LCM 72. For 0 and 24, the GCD is 24 and the LCM is 0.

Euclid’s algorithm

The greatest common divisor is found by repeatedly replacing a pair (a, b) with (b, a mod b) until the second value is zero. The last nonzero remainder is the GCD. Absolute values are used so the answer never depends on the sign you typed.

Building an LCM carefully

For two nonzero inputs, LCM(a, b) = |(a / GCD(a, b)) × b|. Dividing before multiplying avoids unnecessary intermediate growth. The same pairwise rule extends to a list by combining its values one at a time.

Conventions involving zero

This calculator defines GCD(0, 0) as 0 and sets the LCM to 0 whenever any input is zero. The all-zero GCD is an explicit computational convention; the ordinary largest-positive-divisor description does not choose a finite maximum for that case.

What to know

  • The all-zero GCD and any-zero LCM use the stated zero conventions.

Common questions

Can I use fractions or decimals?

No. GCD and LCM here are defined for integer inputs. Multiply rational values by a suitable common denominator first if that matches your problem.

What is the difference between GCD and HCF?

Greatest common divisor and highest common factor refer to the same positive-integer quantity.

How large can an input be?

Each integer may contain up to 100 digits, with at most 30 inputs. The output can be longer than any individual input.

Does the order of the list matter?

The final GCD and LCM do not depend on order. Only the intermediate accumulation trace changes.

Sources & references