LCM & GCD Calculator

Find the least common multiple and the greatest common divisor of any list of whole numbers, step by step.

How to use

  1. Type two or more whole numbers, separated by commas, spaces or line breaks.
  2. The LCM and the GCD appear immediately, with the Euclidean divisions and the multiplication that produced them.
  3. Use the prime factorisation line as a cross-check — it is the method taught in school, shown next to the fast one.

About this tool

The greatest common divisor (GCD, or MDC in Portuguese) is the largest number that divides all of the given numbers exactly. The least common multiple (LCM, or MMC) is the smallest number that all of them divide exactly. GCD(48, 36) is 12, because 12 is the biggest number that fits into both; LCM(4, 6, 8) is 24, the first number every one of them reaches. They are the two ends of the same idea, and they are linked by a simple identity: for any pair, a × b = GCD × LCM.

Instead of listing multiples until something matches, this calculator uses the Euclidean algorithm, which is more than two thousand years old and still the fastest way to do it by hand: divide the larger number by the smaller one, then divide the divisor by the remainder, and repeat until the remainder is zero — the last non-zero remainder is the GCD. The LCM then comes from a × b ÷ GCD. For lists longer than two numbers both are applied in pairs, carrying the running result forward, and every division is printed so you can copy the reasoning into your homework. The prime factorisation of each number is shown alongside as a reference, since that is the method most textbooks teach first.

Outside the classroom these two numbers show up whenever cycles have to line up or quantities have to be split evenly. The LCM gives the common denominator when adding fractions, the moment two gears return to the same position, or when two tasks running every 12 and every 18 minutes coincide again. The GCD tells you the largest identical portion you can cut a set into, or reduces a fraction to lowest terms. The tool accepts whole numbers from 1 to 1,000,000,000 and runs entirely in your browser.

The formula

Euclidean algorithm: gcd(a, b) = gcd(b, a mod b), repeated until the remainder is 0. LCM(a, b) = a × b ÷ gcd(a, b). For longer lists both are applied in pairs: gcd(a, b, c) = gcd(gcd(a, b), c), and the same for the LCM.

Frequently asked questions

What are the LCM and the GCD used for?

The LCM gives the least common denominator when adding fractions and the point where repeating cycles meet again; the GCD reduces fractions to lowest terms and finds the largest equal parts a quantity can be split into.

How does the Euclidean algorithm work?

You divide the larger number by the smaller one and keep the remainder, then divide the previous divisor by that remainder, repeating until the remainder is zero. The last non-zero remainder is the greatest common divisor.

What does a GCD of 1 mean?

It means the numbers are coprime: they share no factor other than 1. In that case the LCM is simply their product, as with 7 and 13, whose LCM is 91.

How many numbers can I enter?

Up to 20 numbers at a time, each between 1 and 1,000,000,000. Very long lists can produce an LCM too large to represent exactly, and the tool says so instead of showing a rounded value.

Do my numbers leave my browser?

No. Everything is calculated in JavaScript on your device, with no requests to any server.

Related tools

Long links? Shorten them for free

Vai.la turns any URL into a short link with click statistics, QR Code and your own biolink.

Vai.la is not responsible for how the tools are used or for decisions made based on their results.