Skip to content
Language:en

GCD and LCM calculator

Greatest common divisor and least common multiple of two or more numbers, with prime factorizations.

Two or more, e.g. 12, 18, 30

Runs entirely in your browser. Your files never leave your device.

About this tool

The greatest common divisor is the largest number that divides all of yours, useful to simplify a fraction or cut lengths into equal pieces with nothing left. The least common multiple is the smallest number they all divide, which gives a common denominator or tells when two cycles line up again, such as buses leaving every 12 and 18 minutes.

Type two or more whole numbers separated by commas or spaces. The calculator returns both values at once and lists the prime factorization of every number, so you can see where the result comes from and copy the working for homework. Very large least common multiples are computed exactly, without rounding.

How it works

  1. Type your whole numbers, separated by commas or spaces.
  2. Read the GCD and the LCM.
  3. Check the prime factorization of each number below.

The GCD uses Euclid’s algorithm, repeated over the list. The LCM uses lcm(a, b) = a × b ÷ gcd(a, b), with exact big-integer arithmetic.

Worked example

Two buses leave the station together, one every 12 minutes and one every 18. The LCM of 12 and 18 is 36, so they leave together again 36 minutes later. Their GCD is 6, the largest interval that fits both timetables.

To simplify 84/126, the GCD of 84 and 126 is 42, so the fraction is 2/3. And to tile a 360 × 270 cm floor with the largest square tiles and no cutting, the GCD of 360 and 270 gives tiles of 90 cm.

Good to know

  • GCD × LCM = the product of the two numbers. It is a quick way to check a result by hand.
  • If the GCD is 1, the numbers share no factor and the fraction they form is already in lowest terms.
  • The prime factorisations shown under the result are the working teachers usually ask for.

Frequently asked questions

Is GCD the same as HCF or GCF?
Yes. Greatest common divisor, highest common factor and greatest common factor are three names for the same number.
How do I use the LCM to add fractions?
The LCM of the denominators is the smallest common denominator. For 1/12 + 1/18, the LCM of 12 and 18 is 36, so the sum is 3/36 + 2/36 = 5/36.
What if the GCD is 1?
The numbers are then called coprime: they share no prime factor, and their LCM is simply their product.