GCD Calculator

GCD of a and b—
LCM of the same pair—

How GCD Calculator is calculated: GCD = the largest number that divides both numbers exactly (found by the Euclidean algorithm)

What is a GCD?

A GCD — greatest common divisor — is the largest number that divides two numbers exactly, with nothing left over. The GCD of 48 and 18 is 6: 6 divides 48 exactly (48 ÷ 6 = 8) and divides 18 exactly (18 ÷ 6 = 3), and no number bigger than 6 does both. The GCD is the biggest shared building block of the two numbers.

Two numbers whose GCD is 1 are called coprime — they share no building block at all. 7 and 13 are coprime, with a GCD of 1, which is why the fraction 7/13 cannot be simplified. The GCD is what tells you whether a fraction can be reduced, and by how much. The same GCD step is what a fraction simplifier uses to reduce a fraction to its lowest terms.

This calculator takes two numbers and returns their GCD and their LCM, the least common multiple. The result updates as you type. Nothing is uploaded, and there is no sign-up.

How a GCD calculator works

The calculator uses the Euclidean algorithm, a method over two thousand years old. Divide the bigger number by the smaller and keep the remainder. Then divide the previous divisor by that remainder, and keep going until the remainder is zero. The last divisor before zero is the GCD.

For 48 and 18: 48 ÷ 18 = 2 remainder 12. Then 18 ÷ 12 = 1 remainder 6. Then 12 ÷ 6 = 2 remainder 0. The remainder hit zero, so the last divisor, 6, is the GCD. Three divisions, no guessing, and it works for numbers of any size.

The LCM comes from the GCD with one formula: LCM = |a × b| ÷ GCD. For 48 and 18, that is 864 ÷ 6 = 144, so the least common multiple is 144. The calculator shows both results because the two numbers are tied together by that formula — find one and the other follows.

The Euclidean algorithm step by step

The algorithm works because of one simple fact: any number that divides both a and b also divides their remainder, and any number that divides b and the remainder also divides a. So replacing the pair (a, b) with the pair (b, remainder) never changes the GCD — it only makes the numbers smaller, until the remainder is zero and the answer is staring at you.

Try it on 12 and 18: 18 ÷ 12 = 1 remainder 6, then 12 ÷ 6 = 2 remainder 0, so the GCD is 6. Try it on 7 and 13, which are coprime: 13 ÷ 7 = 1 remainder 6, 7 ÷ 6 = 1 remainder 1, 6 ÷ 1 = 6 remainder 0, so the GCD is 1. The algorithm reaches 1 whenever the numbers share nothing.

The beauty of the method is its speed. Even for numbers with ten digits, the Euclidean algorithm finishes in a few dozen steps, because each division at least halves the bigger number. Listing all the divisors of a ten-digit number would take far longer — the algorithm is why GCD calculations are instant.

The algorithm has a useful side effect: the steps it takes also produce the numbers needed to solve equations of the form ax + by = GCD(a, b). That extended version powers modular arithmetic, which is the maths behind clocks, calendars and the encryption mentioned above — one short algorithm doing far more than finding a divisor.

A worked example: 48 and 18, 12 and 18, 7 and 13

Start with the defaults: 48 and 18. The GCD is 6, as the Euclidean algorithm showed above, and the LCM is 48 × 18 ÷ 6 = 144. Check it: 144 is the smallest number divisible by both 48 (144 ÷ 48 = 3) and 18 (144 ÷ 18 = 8).

Now 12 and 18. The GCD is 6, and the LCM is 12 × 18 ÷ 6 = 36. Both numbers divide 36 exactly — 36 ÷ 12 = 3 and 36 ÷ 18 = 2 — and no smaller number does both, which is what least common multiple means.

Finally the coprime pair: 7 and 13. The GCD is 1, because they share no divisor bigger than 1, and the LCM is 7 × 13 ÷ 1 = 91. When the GCD is 1, the LCM is simply the product of the two numbers — a useful check whenever you suspect two numbers are coprime.

A quick mental check for any GCD answer is to divide both inputs by it. For 48 and 18 with a GCD of 6, the quotients are 8 and 3 — and 8 and 3 are coprime, sharing no divisor bigger than 1. If the two quotients still share a divisor, the GCD you found was too small, and the real GCD is bigger.

Where the GCD actually gets used

Simplifying fractions is the everyday use. The fraction 48/18 looks messy, but dividing top and bottom by the GCD of 6 gives 8/3 — the same value in simplest form. Every fraction you have ever reduced was a GCD calculation, done by hand or by a calculator.

Tiling and cutting use the GCD too. A floor 48 cm by 18 cm tiled with the largest possible square tiles needs tiles 6 cm on a side — the GCD — because 6 is the biggest length that fits both sides exactly. A carpenter cutting equal lengths from two boards reaches for the same number.

Scheduling runs on the GCD as well. Two buses leaving every 48 and 18 minutes coincide every 144 minutes — the LCM — and the GCD of 6 tells you the two schedules share a 6-minute grid. Music uses the same idea: rhythms that repeat every 48 and 18 beats line up every 144 beats, and a ratio calculator helps express those repeating patterns as simple ratios.

Cryptography and computer science depend on the GCD. The RSA encryption system, which protects most of the web, needs two numbers to be coprime — a GCD of 1 — and the Euclidean algorithm is the test that proves it. Every secure connection your browser makes relies on a GCD check running silently in the background.

GCD calculator vs LCM calculator

The GCD and the LCM are two sides of one relationship. The GCD is the largest number that divides both numbers; the LCM is the smallest number both numbers divide. For 48 and 18, the GCD is 6 and the LCM is 144, and the two are linked by the formula GCD × LCM = a × b — 6 × 144 = 864 = 48 × 18.

Use the GCD when you are splitting things down — simplifying a fraction, cutting equal lengths, finding the biggest shared piece. Use the LCM calculator when you are lining things up — finding when two cycles coincide, adding fractions with different denominators, or scheduling repeating events.

This calculator gives you both answers from one pair of inputs, so the choice is really about which row you read. The GCD is the main result here; the LCM page makes the LCM the main result, with the GCD alongside it.

Common GCD mistakes

The most common mistake is confusing the GCD with the LCM. The GCD of 48 and 18 is 6 — a small number, never bigger than the smaller input. The LCM is 144 — a big number, never smaller than the bigger input. If your GCD comes out bigger than your smallest number, you have found the LCM by accident.

The second mistake is stopping the Euclidean algorithm one step early. The GCD is the last divisor before the remainder hits zero, not the last remainder. For 48 and 18, the remainders are 12, then 6, then 0 — the GCD is 6, the last divisor, not 0 and not 12.

The third mistake is assuming coprime numbers have a GCD of 0. They have a GCD of 1 — 1 divides everything. A GCD of 0 only happens when both numbers are 0, which is the one case where the GCD is genuinely undefined and the calculator returns 0 rather than guessing.

The fourth mistake is using the GCD on numbers that are not whole. The GCD is defined for integers; for decimals, round or scale first. 4.8 and 1.8 share a GCD of 0.6 only after scaling by 10 to 48 and 18 — and a scientific calculator can handle the scaling step if the decimals are awkward. A fifth mistake is assuming the GCD of three numbers is found by taking the GCD of the first two and stopping. It is found by taking the GCD of the result with the third number: GCD(48, 18, 12) is GCD(6, 12) = 6. Pair the numbers one at a time and the method extends to any count.

How to use this GCD calculator

Type two whole numbers into the boxes — 48 and 18 are the defaults. The GCD and the LCM of the pair update live as you type, so you can watch the GCD change as you change either number. Decimals are rounded down to whole numbers, and negative numbers are treated as their positive versions, since the GCD depends only on divisibility.

Try 12 and 18 to check the tool: the GCD is 6 and the LCM is 36. Then try 7 and 13: the GCD is 1 and the LCM is 91, the product of the two numbers, which confirms they are coprime.

Everything runs in your browser. No account, no upload, no data sent anywhere — your numbers never leave your device. Use it for fractions, tiling, and scheduling, and pair it with the ratio calculator whenever a GCD is the first step toward a simplified ratio.

Frequently Asked Questions

The GCD is 6. It divides 48 exactly (48 ÷ 6 = 8) and 18 exactly (18 ÷ 6 = 3), and no larger number does both. The LCM of the same pair is 144.

Divide the bigger number by the smaller and keep the remainder, then divide the previous divisor by that remainder, repeating until the remainder is zero. For 48 and 18: 48 ÷ 18 leaves 12, 18 ÷ 12 leaves 6, and 12 ÷ 6 leaves 0 — so the GCD is 6.

The numbers are coprime — they share no divisor bigger than 1. For 7 and 13 the GCD is 1, so the fraction 7/13 cannot be simplified, and their LCM is simply their product, 91.

GCD × LCM = a × b. For 48 and 18, 6 × 144 = 864 = 48 × 18. Find one and the other follows from the formula LCM = |a × b| ÷ GCD.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.