GCD Calculator

Find the greatest common divisor (GCD) of two or more whole numbers using the Euclidean algorithm with a clear step-by-step calculation.

Calculate the greatest common divisor

Enter two or more integers separated by commas or spaces. The calculator finds the largest positive integer that divides every number without a remainder.

Please enter at least two valid integers.

Your result

—

—

Numbers —
GCD —
Number of values —

Step-by-step calculation

Step 1: Identify the numbers
—
Step 2: Apply the Euclidean algorithm
—
Step 3: Continue until the remainder is zero
—
Step 4: Final answer
—

What is the GCD?

The greatest common divisor, or GCD, of two or more integers is the largest positive integer that divides each of them without leaving a remainder.

The GCD is also called the greatest common factor (GCF) in many mathematical contexts.

How is the GCD calculated?

This calculator uses the Euclidean algorithm. The algorithm repeatedly divides the larger number by the smaller number and replaces the pair with the divisor and the remainder.

When the remainder becomes zero, the last nonzero divisor is the GCD.

GCD calculator example

Find the GCD of 48 and 18.

48 ÷ 18 = 2 remainder 12

18 ÷ 12 = 1 remainder 6

12 ÷ 6 = 2 remainder 0

Therefore:
GCD(48, 18) = 6

The greatest common divisor of 48 and 18 is 6.

Formula used

Euclidean algorithm:

gcd(a, b) = gcd(b, a mod b)

Continue until:
a mod b = 0

The last nonzero value of b is the GCD.

Why is the GCD useful?

The greatest common divisor helps identify the largest whole-number unit shared by two or more integers. It is useful whenever a problem involves grouping, simplifying, factoring, or finding a common measurement without leaving a remainder.

For example, if 48 items and 18 items must be divided into identical groups with no items left over, the largest possible number of equal groups is determined by their GCD, which is 6.

How to use this GCD calculator

Enter at least two integers in the input field. You can separate the values with commas or spaces, including positive or negative whole numbers. Select Calculate GCD to see the answer and the Euclidean algorithm steps.

The calculator accepts multiple values, so you can calculate the GCD of three or more integers in one operation. If the entered values are invalid or all values are zero, an explanatory message is displayed instead of a result.

GCD and factors

A factor is a whole number that divides another number exactly. The GCD is the largest factor common to every number in the set. One way to find it manually is to list the factors of each number and identify the largest factor they share.

For small numbers this method is straightforward, but listing factors becomes inefficient for larger numbers. The Euclidean algorithm used by this calculator is generally much faster because it repeatedly reduces the problem using remainders.

GCD using the Euclidean algorithm

The Euclidean algorithm is based on the fact that the common divisors of two numbers are unchanged when the larger number is replaced by the remainder after division by the smaller number.

gcd(a, b) = gcd(b, a mod b)

Repeat the process until the remainder is zero. The last nonzero remainder is the GCD.

For example, for 48 and 18, the sequence of remainders is 12, then 6, then 0. Therefore, the GCD is 6.

GCD of more than two numbers

The GCD of several integers can be found by calculating the GCD of two numbers first and then using that result with the next number. For numbers a, b, and c:

gcd(a, b, c) = gcd(gcd(a, b), c)

This property allows the calculator to process a list of integers one pair at a time while preserving the final common divisor.

GCD of negative numbers

The sign of an integer does not change its positive common divisors. For that reason, the calculator uses the absolute values of entered integers when determining the GCD. For example, the GCD of −48 and 18 is 6.

GCD and LCM: what is the difference?

The GCD is the greatest positive integer that divides all selected numbers. The least common multiple (LCM), on the other hand, is the smallest positive multiple shared by the numbers. They answer different questions: GCD is useful for common grouping and simplification, while LCM is useful for finding a shared multiple or repeating interval.

For two positive integers a and b, their relationship can be written as:

GCD(a, b) × LCM(a, b) = |a × b|

GCD in fractions and simplifying ratios

The GCD is commonly used to simplify fractions and ratios. To reduce a fraction, divide both the numerator and denominator by their GCD. For example, the GCD of 24 and 36 is 12, so 24/36 can be reduced to 2/3.

The same idea applies to ratios. A ratio such as 18:24 can be simplified by dividing both terms by their GCD, 6, giving 3:4.

Common mistakes when finding a GCD

One common mistake is stopping before the remainder becomes zero. Another is choosing a divisor that works for only one of the numbers rather than every number. When using factor lists, it is also easy to overlook a larger common factor.

For manual calculations, check that the final GCD divides every original integer exactly. If a larger positive integer also appears to divide every value, the result should be checked again.

Frequently Asked Questions

What does GCD stand for?

GCD stands for greatest common divisor. It is the largest positive integer that divides each selected integer without a remainder.

Is GCD the same as GCF?

Yes. Greatest common factor (GCF) is another commonly used name for the same mathematical concept.

Can I calculate the GCD of more than two numbers?

Yes. Enter three or more integers separated by commas or spaces. The calculator reduces the values pair by pair.

Can the calculator handle negative numbers?

Yes. Negative integers are accepted, and their absolute values are used when calculating the positive GCD.

What is the GCD of two coprime numbers?

If two integers have no common positive divisor other than 1, their GCD is 1. Such numbers are called relatively prime or coprime.

What happens if I enter only zeros?

The calculator reports that the GCD of a list containing only zeros is not defined and asks for at least one nonzero integer.

How do I verify a GCD result?

Divide every original integer by the reported GCD. Each division should have a remainder of zero. You can also review the Euclidean algorithm steps shown by the calculator.

Why is the Euclidean algorithm useful?

It finds a GCD without requiring a complete list of factors. Each division reduces the problem until the remainder reaches zero, making it efficient even when the input numbers are relatively large.

Related calculators

Important: This calculator is provided for general informational and educational purposes only. The results are based on the integers entered and standard mathematical methods. Calculations should be independently verified when high precision or formal mathematical proof is required.