Smekys
Ad Space

GCD Calculator

Free GCD calculator: instantly find the greatest common divisor of two integers with the Euclidean algorithm, plus LCM and the reduced ratio.

Enter Values

integer

The first non-negative whole number (for example, 48).

integer

The second non-negative whole number (for example, 18).

Result

Greatest Common Divisor (GCD)
6
Least Common Multiple (LCM)
144
a ÷ GCD (simplified)
8
b ÷ GCD (simplified)
3

The greatest common divisor (GCD) of two whole numbers is the largest number that divides both of them evenly with nothing left over. It sounds like an abstract idea from middle-school math, but it shows up everywhere: simplifying a fraction, cutting two lengths of board into the longest equal pieces, splitting a group of people into the largest identical teams, or figuring out how often two repeating cycles line up. This GCD calculator takes two integers and returns the greatest common divisor, the least common multiple (LCM), and the reduced ratio between them — all in a single step.

Type any two non-negative integers into the boxes and the result appears instantly. The engine behind it is the Euclidean algorithm, the same 2,300-year-old method that still runs inside every modern math library because it is fast, exact, and needs no factoring.

How to Use

  1. Enter the First Integer (a) — the larger of the two if you happen to know it, though order does not matter for the result.
  2. Enter the Second Integer (b) — the other whole number you want to compare.
  3. Read the Greatest Common Divisor (GCD) in the highlighted result card. This is the largest number that divides both inputs with a remainder of zero.
  4. Check the Least Common Multiple (LCM). It is the smallest number that both inputs divide into evenly, and it is automatically derived from the GCD.
  5. Use the two simplified figures (a ÷ GCD and b ÷ GCD) to reduce a ratio or fraction to its lowest terms.

The calculator accepts zero: the GCD of 0 and any number n is n itself, because every number divides zero. Negative integers are not accepted because divisibility is defined on non-negative whole numbers; if you need the result for a negative pair, just enter the absolute values.

How the Euclidean Algorithm Works

Instead of listing every factor of both numbers and hunting for the biggest shared one — slow and error-prone — the Euclidean algorithm repeatedly replaces the larger number by its remainder after dividing by the smaller one.

gcd(a, b) = gcd(b, a mod b), repeating until b becomes 0. At that point the remaining value of a is the GCD.

Work through gcd(48, 18) by hand:

  • 48 ÷ 18 leaves a remainder of 12, so now we want gcd(18, 12).
  • 18 ÷ 12 leaves a remainder of 6, so now we want gcd(12, 6).
  • 12 ÷ 6 leaves a remainder of 0, so we stop. The answer is 6.

Notice we never had to list the factors of 48 or 18 at all. For giant numbers — say two ten-digit integers — the naive factoring approach would bog down, but the Euclidean algorithm still finishes in a handful of steps, because the size of the numbers drops at least by half on every two iterations. That is why it is the reference implementation used in serious math software.

From the GCD, the LCM follows directly: lcm(a, b) = |a × b| ÷ gcd(a, b). For 48 and 18 that is (48 × 18) ÷ 6 = 864 ÷ 6 = 144. The simplified ratio is 48 ÷ 6 = 8 and 18 ÷ 6 = 3, so the ratio 48:18 reduces cleanly to 8:3.

Where the GCD Shows Up in Real Life

You do not need to be a mathematician to need this number. If you have a $60 payment due every 48 days and another bill due every 18 days, the LCM tells you the first date both bills land on the same day — 144 days — so you can plan your budget once instead of twice. If you are tiling a wall that is 48 inches wide and 18 inches tall, the GCD of 6 tells you the largest square tile that covers the wall with no cutting. If you have 48 red balloons and 18 blue ones and want to make the greatest number of identical balloon bouquets, 6 bouquets is the maximum, each carrying 8 red and 3 blue.

Examples

Example 1 — Two everyday numbers. Enter a = 48 and b = 18. The GCD is 6, the LCM is 144, and the reduced ratio is 8:3. If you were splitting a $48 dinner tab and an $18 parking fee among the largest number of identical shares, 6 people would be the clean answer — each owing $8 for food and $3 for parking.

Example 2 — One of the numbers is zero. Enter a = 0 and b = 15. Because every integer divides zero, the greatest common divisor is simply 15, and the simplified pair is 0 and 1. The LCM in this case is 0.

Example 3 — Very large integers. Enter a = 1,000,000 and b = 500,000. The Euclidean algorithm returns a GCD of 500,000 immediately (one step), an LCM of 1,000,000, and a reduced ratio of 2:1. The engine handles numbers well beyond a million without any loss of precision.

Example 4 — Coprime numbers. Enter a = 1,234,567 and b = 7,654,321. These share no common factor greater than 1, so the GCD is 1, and the LCM is the full product of the two. A GCD of 1 means the two numbers are coprime, which matters in cryptography and fraction reduction.

FAQ

What does GCD stand for?

GCD stands for greatest common divisor. It is the largest whole number that divides two given integers exactly, with no remainder left over. You may also see it called GCF (greatest common factor), HCF (highest common factor), or sometimes GCM (greatest common measure) — all of them mean the same thing.

How is the greatest common divisor calculated?

The fastest method is the Euclidean algorithm: repeatedly replace the larger number with the remainder of dividing it by the smaller one, until the remainder is zero. The last non-zero remainder is the GCD. For example, gcd(48, 18) reduces through gcd(18, 12) and gcd(12, 6) to the answer 6. This calculator runs that algorithm for you automatically.

What is the difference between GCD and LCM?

The GCD is the largest number that divides both inputs; the LCM (least common multiple) is the smallest number that both inputs divide into. They are close cousins, linked by the formula lcm(a, b) = |a × b| ÷ gcd(a, b). The GCD helps you split things into the largest equal pieces; the LCM helps you find when two repeating cycles coincide.

What is the GCD when one number is zero?

The GCD of 0 and any number n is n itself, because every integer divides zero. So gcd(0, 15) = 15. The only special case is gcd(0, 0), which is undefined, though most calculators return 0 as a convenience.

Can I use negative numbers?

Mathematically the GCD is always a non-negative value, and sign does not matter — gcd(−48, 18) equals gcd(48, 18) = 6. To keep the inputs unambiguous, this calculator asks for non-negative integers; if you have a negative value, simply enter its absolute value. The result will be identical.

Is the GCD of two numbers ever 1?

Yes. When two integers share no common factor other than 1, they are called coprime, and their GCD is 1. For example, gcd(1,234,567, 7,654,321) = 1. Coprime numbers show up constantly in encryption, musical tuning, and fraction simplification.

How do I simplify a fraction with the GCD?

Divide both the numerator and the denominator by their GCD. To reduce 18/48, compute the GCD (which is 6), then divide top and bottom by 6: 18 ÷ 6 = 3 and 48 ÷ 6 = 8, so the fraction simplifies to 3/8. The two "simplified" figures in the result card do exactly this for you.

Disclaimer

This GCD calculator is provided for informational purposes only and does not constitute mathematical, academic, financial, or other professional advice. Results are computed from the non-negative integers you enter using the Euclidean algorithm and are exact for whole-number inputs, but you are responsible for verifying any outcome you rely on — especially in budgeting, scheduling, homework, or engineering. Always cross-check important calculations with an authoritative source.

Related Calculators

Disclaimer

Results are estimates for illustration only. Verify important figures independently.