Boneyard Tools

LCM and GCD Calculator

Type any list of whole numbers and this calculator returns their greatest common divisor and least common multiple side by side. It folds both results across the entire list, not just a pair, using Euclid's algorithm so the answer is exact even for large values. Negatives and zeros are accepted and handled by the usual mathematical conventions.

How to find the GCD and LCM

  1. Type your integers into the 'Integers' box, separating them with commas or spaces.
  2. Add as many numbers as you need; the tool updates as you type.
  3. Read the GCD (HCF) card for the largest value dividing every number.
  4. Read the LCM card for the smallest value that every number divides into.
  5. Click the copy icon on either card to grab that result.

Examples

GCD and LCM of 12, 18, 24

12, 18, 24
GCD 6, LCM 72

Coprime set 2, 3, 4

2 3 4
GCD 1, LCM 12

A single pair, 12 and 18

12, 18
GCD 6, LCM 36

Frequently asked questions

What is the difference between GCD and LCM?

The GCD is the largest integer that divides every number in your list without a remainder. The LCM is the smallest positive integer that each of your numbers divides into evenly. They answer opposite questions: the biggest shared factor versus the smallest shared multiple.

How is the GCD calculated?

It uses Euclid's algorithm. The calculator repeatedly replaces the larger number with the remainder of dividing it by the smaller one until the remainder hits zero, at which point the surviving value is the GCD. For three or more numbers it applies this pairwise across the list.

How is the LCM found from the GCD?

For any pair the least common multiple equals the absolute value of the product divided by the GCD, so lcm(a, b) = |a times b| / gcd(a, b). The calculator chains this across the whole list to get the overall LCM.

Can I enter more than two numbers?

Yes. Enter as many integers as you like separated by commas or spaces. The GCD and LCM are computed by folding the operation over every value, so a list of ten numbers works the same way as a single pair.

What happens if I include zero?

The GCD treats zero as a value it divides, so gcd(0, n) is the absolute value of n. Any LCM that involves a zero is defined as zero by convention, and the tool reports zero in that case.

Does it accept negative numbers?

Yes. Signs are ignored for both results because divisibility depends on magnitude, so the GCD and LCM are always reported as non-negative integers.

Why must the inputs be whole numbers?

GCD and LCM are only defined for integers. If you type a decimal or a value that is not a whole number, the tool flags it and asks for an integer instead of guessing.

Is HCF the same as GCD?

Yes. Highest common factor (HCF) and greatest common divisor (GCD) are two names for the same thing, which is why the result card is labelled GCD (HCF).

Is my input private?

Yes. The calculation runs entirely in your browser with JavaScript, and nothing you type is sent to a server.

Learn more

Related tools