ZapKit

GCD and LCM Calculator

Find the greatest common divisor (also called HCF) and the least common multiple of two or more whole numbers, with each number's prime factors.

What are GCD and LCM?

The greatest common divisor (GCD) of some numbers is the largest number that divides all of them exactly. The least common multiple (LCM) is the smallest number that all of them divide into exactly.

They come up constantly in school maths and in practical problems: simplifying fractions uses the GCD, adding fractions uses the LCM of the denominators, cutting materials into equal pieces with no waste uses the GCD, and working out when timetables or gears line up again uses the LCM. This calculator finds both for any list of whole numbers and shows the prime factors behind them.

How to use the GCD and LCM Calculator

  1. 1.Enter whole numbers

    Two or more, separated by commas or spaces.

  2. 2.Read GCD and LCM

    Both are shown, with whether the numbers are coprime.

  3. 3.Check the factors

    The table lists each number's prime factorisation.

Example: 12, 18 and 30

Three numbers and their prime factors:

12
2² × 3
18
2 × 3²
30
2 × 3 × 5
GCD / LCM
6 / 180

LCM(a, b) = a × b ÷ GCD(a, b)

Each number shares the factor 2 × 3 = 6, and 180 is the first number all three divide.

How they're found

The greatest common divisor is calculated with Euclid's algorithm, which repeatedly replaces the larger number with the remainder of dividing it by the smaller until the remainder is zero. It's fast even for very large numbers.

The least common multiple of two numbers is their product divided by their GCD, applied across the list one number at a time. In prime factor terms, the GCD takes the lowest power of each shared prime and the LCM takes the highest power of every prime.

Frequently asked questions

Is GCD the same as HCF?

Yes. Greatest common divisor, greatest common factor and highest common factor all mean the same thing.

What does coprime mean?

Numbers whose only common divisor is 1, like 8 and 15.

When do I need the LCM?

To find a common denominator for fractions, or when two repeating events will next happen together.

Can I use more than two numbers?

Yes. Enter as many as you need.

More Utilities tools