Greatest Common Divisor Calculator

Calculate the greatest common divisor (GCD) between multiple integers instantly.

Results are calculated automatically as you enter data.

Data inputs
Row Integer Value
Greatest Common Divisor 0

Enter at least two integers.

▼ See explanations and tips below ▼

What Is the Greatest Common Divisor?

The greatest common divisor, usually written as GCD, is the largest positive integer that divides two or more integers with no remainder. In school arithmetic, the same idea is often called the greatest common factor, because it is the largest factor shared by the numbers.

For two integers \(a\) and \(b\), the idea can be written as:

$$ \gcd(a,b)=\max\{d\in\mathbb{Z}_{>0}: d\mid a \text{ and } d\mid b\} $$

Here, \(d \mid a\) means “\(d\) divides \(a\) evenly.” For example, \(6 \mid 24\) because \(24 \div 6 = 4\) with no remainder.

The GCD answers a simple question: What is the biggest whole-number size that fits evenly into every number in the group? That makes it useful for simplifying fractions, comparing divisibility, grouping items evenly, working with ratios, and understanding number theory.


Why the GCD Matters

The GCD matters because it reveals the largest shared structure inside a group of integers. Instead of only checking whether one number divides another, the GCD tells you the greatest divisor that all of the numbers have in common.

A few common uses include:

  • Simplifying fractions: Divide the numerator and denominator by their GCD to reduce the fraction.
  • Finding equal group sizes: If you have several quantities and want equal groups with nothing left over, the GCD gives the largest possible group size.
  • Comparing ratios: Dividing both parts of a ratio by the GCD gives the simplest whole-number ratio.
  • Preparing for LCM problems: The GCD and least common multiple are closely related, but they answer opposite questions: the GCD finds a shared divisor, while the LCM finds a shared multiple.
  • Learning number theory: Concepts such as divisibility, coprime integers, modular arithmetic, and the Euclidean algorithm all build on the GCD.

Key Terms to Know

  • Integer: A whole number, including negative numbers and zero, such as \(-8\), \(0\), and \(25\).
  • Divisor: A number that divides another number evenly, with no remainder.
  • Factor: Another word for a divisor, often used in arithmetic and algebra.
  • Common divisor: A divisor shared by two or more integers.
  • Greatest common divisor: The largest positive common divisor of the given integers.
  • Remainder: What is left after division when the division is not exact.
  • Modulo: The operation that returns the remainder after division.
  • Coprime integers: Integers whose GCD is \(1\). They share no positive divisor larger than \(1\).
  • Euclidean algorithm: A repeated-division method for finding the GCD efficiently.

How the Euclidean Algorithm Works

One way to find a GCD is to list all factors of each number and look for the largest shared factor. That works well for small numbers, but it becomes slow when the numbers are large.

The Euclidean algorithm is faster because it uses remainders. The key fact is that replacing a larger number by its remainder after division does not change the GCD.

For integers \(a\) and \(b\), with \(b \ne 0\), divide \(a\) by \(b\):

$$ a=q\times b+r,\quad 0\le r<|b| $$

Where:

  • \(a\) is the number being divided.
  • \(b\) is the divisor.
  • \(q\) is the integer quotient.
  • \(r\) is the remainder.

The Euclidean algorithm uses the relationship:

$$ \gcd(a,b)=\gcd(b,r) $$

Then it repeats the same idea with \(b\) and \(r\). When the remainder becomes \(0\), the last nonzero divisor is the GCD.

For more than two integers, the same two-number process can be applied in sequence. First find the GCD of the first two numbers, then find the GCD of that result and the next number, and continue until all inputs have been used.


Examples of the GCD in Practice

Example 1: Finding the GCD by Listing Factors

Find the GCD of \(24\) and \(36\).

The positive factors of \(24\) are:

$$ 1,2,3,4,6,8,12,24 $$

The positive factors of \(36\) are:

$$ 1,2,3,4,6,9,12,18,36 $$

The common factors are:

$$ 1,2,3,4,6,12 $$

The largest common factor is \(12\), so:

$$ \gcd(24,36)=12 $$

Example 2: Finding the GCD with the Euclidean Algorithm

Find the GCD of \(252\) and \(105\).

Start by dividing the larger number by the smaller number:

$$ 252=2\times105+42 $$

Now replace the pair \(252,105\) with \(105,42\):

$$ 105=2\times42+21 $$

Now replace the pair \(105,42\) with \(42,21\):

$$ 42=2\times21+0 $$

The remainder is now \(0\), so the last nonzero divisor is \(21\):

$$ \gcd(252,105)=21 $$

Example 3: Simplifying a Fraction

To simplify the fraction \(\frac{84}{126}\), first find the GCD of \(84\) and \(126\).

Both numbers are divisible by \(42\), and \(42\) is the greatest common divisor:

$$ \gcd(84,126)=42 $$

Divide the numerator and denominator by \(42\):

$$ \frac{84}{126}=\frac{84\div42}{126\div42}=\frac{2}{3} $$

So the simplified fraction is:

$$ \frac{2}{3} $$

Example 4: Negative Numbers and Zero

The GCD is usually reported as a nonnegative value. Negative signs do not make the GCD negative, because divisibility is based on the absolute size of the factors.

For example:

$$ \gcd(-48,180,0)=\gcd(48,180,0) $$

Use the Euclidean algorithm on \(48\) and \(180\):

$$ 180=3\times48+36 $$
$$ 48=1\times36+12 $$
$$ 36=3\times12+0 $$

The GCD of \(48\) and \(180\) is \(12\). Since \(12\) also divides \(0\), adding zero to the input list does not change the result:

$$ \gcd(-48,180,0)=12 $$

This is different from the all-zero case. Every positive integer divides \(0\), so there is no single largest positive divisor shared by only zeros. For that reason, an all-zero input is treated as undefined.


How to Interpret the Result

The GCD result is an exact integer. It tells you the largest positive integer that divides every valid entered integer evenly.

A result of \(1\) means the entered integers are coprime as a group. They may still have individual factors, but they do not share any positive factor larger than \(1\).

A result greater than \(1\) means the numbers share a nontrivial common divisor. The larger the GCD is relative to the input values, the more common divisibility structure the numbers share.

For negative inputs, interpret the result using absolute values. For example, \(\gcd(-18,30)\) is \(6\), not \(-6\).

For multiple integers, the result must divide every entered integer. If the result is \(d\), then each input can be written as \(d\) times another integer.

The result area may also show a status instead of a numeric GCD:

  • -- means there are not yet at least two valid integers to calculate.
  • Invalid input means at least one entered or imported value is not accepted as an integer.
  • Undefined means every entered value is zero.

Common Mistakes and Misconceptions

Confusing GCD with LCM. The GCD is the largest number that divides all the inputs. The LCM is the smallest positive number that all the inputs divide into. For \(12\) and \(18\), the GCD is \(6\), but the LCM is \(36\).

Using decimals or fractions. The GCD is an integer concept. Values such as \(4.5\), \(\frac{3}{4}\), or mixed numbers are not valid integer inputs here.

Rounding too early. There is no rounding in a GCD calculation. If a value is not already an integer, it should not be rounded and entered as though it were the original value.

Assuming blank rows count as zero. Blank rows are ignored. They are not treated as \(0\) and do not affect the result.

Entering only one number. A common divisor compares at least two values. Enter at least two valid non-blank integers before expecting a GCD result.

Expecting a negative GCD. The GCD is reported as a nonnegative value. Negative inputs are handled by their absolute values.

Using a leading plus sign. A value such as \(+12\) may look like an integer, but this calculator accepts standard integer strings without a leading plus sign. Enter \(12\) instead.

Pasting labels or units with the numbers. Imported values should be numbers only. Text such as apples, cm, n=, or other labels can make the import invalid.


When to Use the GCD

Use the GCD when you need the largest whole-number divisor shared by a set of integers.

Common use cases include:

  • Reducing fractions to lowest terms.
  • Simplifying whole-number ratios.
  • Splitting quantities into the largest equal groups with no leftovers.
  • Checking whether numbers are coprime.
  • Solving divisibility and modular arithmetic problems.
  • Understanding Euclidean algorithm steps in number theory.
  • Preparing for calculations involving the least common multiple.

Limitations and Things to Keep in Mind

The GCD applies to integers. It does not directly apply to decimals, fractions, percentages, measurements with units, or scientific notation unless those values are first converted into appropriate integers for the problem.

The calculation is exact for accepted integer inputs. There are no decimal places and no rounding rules because the result is a whole number.

Zero needs special care. The GCD of a nonzero integer and zero is the absolute value of the nonzero integer. But when every entered value is zero, the result is undefined because there is no greatest positive integer that divides all the values.

Very large integers can be handled as exact integer strings, but practical limits still depend on the browser, device memory, and processing capacity.

The GCD tells you only about shared integer divisibility. It does not tell you whether a set of numbers is “close,” whether one number is more important than another, or how to interpret a result outside the arithmetic context that produced the numbers.


How to Use This Calculator

  1. Enter an integer in each of the first two rows.
  2. Add more rows if you want to find the GCD of more than two integers.
  3. Leave unused rows blank; blank rows are ignored.
  4. To enter many values quickly, use the import option and paste integers separated by spaces, commas, semicolons, tabs, or line breaks.
  5. Review the GCD result, the inputs used, the calculation summary, and the Euclidean algorithm steps.
  6. If a validation message appears, check for decimals, fractions, scientific notation, leading plus signs, symbols, labels, or too few valid integers.

Frequently Asked Questions

Is the GCD the same as the greatest common factor?

Yes. For integer arithmetic, the greatest common divisor and greatest common factor refer to the same idea: the largest positive whole number that divides all the given numbers evenly.


Can the GCD be negative?

No. The GCD is reported as a nonnegative integer. Negative inputs are handled using their absolute values, so \(\gcd(-12,18)=6\).


What is the GCD of a number and zero?

If one number is nonzero, the GCD of that number and zero is the absolute value of the nonzero number. For example, \(\gcd(25,0)=25\). If all entered values are zero, the result is undefined.


Why does the Euclidean algorithm use remainders?

When \(a=q\times b+r\), any common divisor of \(a\) and \(b\) also divides the remainder \(r\), and any common divisor of \(b\) and \(r\) also divides \(a\). That is why \(\gcd(a,b)\) equals \(\gcd(b,r)\), allowing the problem to shrink until the remainder is zero.


How do you find the GCD of more than two numbers?

Find the GCD of the first two numbers, then find the GCD of that result and the next number. Continue through the list until every number has been included.


What does it mean if the GCD is 1?

A GCD of \(1\) means the numbers share no positive divisor larger than \(1\). For two numbers, this means they are coprime, also called relatively prime.


Sources and References

Books and Open Textbooks

  1. Seçkin Demirbaş and Andrew Rechnitzer. PLP: An Introduction to Mathematical Proof. Section 9.5, “Greatest divisors, Bézout and the Euclidean algorithm.” University of British Columbia. Accessed July 4, 2026. https://personal.math.ubc.ca/~PLP/book/sec-euclid.html
  2. John Hammond. Discrete Math for Shockers. Section 3.3, “GCDs and The Euclidean Algorithm.” Wichita State University. Accessed July 4, 2026. https://www.math.wichita.edu/discrete-book/section-gcd-euclid.html
  3. OpenStax. Prealgebra 2e. Section 2.5, “Prime Factorization and the Least Common Multiple.” OpenStax, 2020. Accessed July 4, 2026. https://openstax.org/books/prealgebra-2e/pages/2-5-prime-factorization-and-the-least-common-multiple
  4. OpenStax. Elementary Algebra 2e. Section 7.1, “Greatest Common Factor and Factor by Grouping.” OpenStax, 2020. Accessed July 4, 2026. https://openstax.org/books/elementary-algebra-2e/pages/7-1-greatest-common-factor-and-factor-by-grouping