GCD Calculator — Greatest Common Divisor

Calculate the Greatest Common Divisor (GCD) of two or more numbers using the Euclidean algorithm or prime factorization method. View step-by-step solutions, Bézout coefficients, LCM, and coprimalit...

GCD
12
The greatest common divisor of 48, 36 is 12
LCM
144
Least common multiple (related): 144
Product of Numbers
1,728
48 × 36 = 1,728
GCD × LCM
1,728
For two numbers: GCD × LCM = 1,728 = product
Coprime?
No
They share common factor(s) — GCD is 12
Bézout Coefficients
x=1, y=-1
1×48 + -1×36 = 12

GCD as Fraction of Each Number

4825.0%
3633.3%

Euclidean Algorithm Steps

Stepabq = ⌊a/b⌋r = a mod b
14836112
2361230

When remainder = 0, the last non-zero remainder is the GCD: 12

GCD Properties Reference
PropertyFormula
Commutativegcd(a, b) = gcd(b, a)
Associativegcd(a, gcd(b, c)) = gcd(gcd(a, b), c)
Identitygcd(a, 0) = a
Idempotentgcd(a, a) = a
Product relationgcd(a, b) × lcm(a, b) = |a × b|
Bézout's identity∃ x, y ∈ ℤ : ax + by = gcd(a, b)
Distributivegcd(ka, kb) = k · gcd(a, b)
Planning notes, formulas, and examples

About the GCD Calculator — Greatest Common Divisor

The **GCD Calculator** finds the greatest common divisor of two or more integers, meaning the largest positive integer that divides every input with no remainder. In practice, it is the cleanest way to reduce fractions, compare shared factors, and support number-theory work that depends on exact divisibility.

You can solve it with the Euclidean algorithm or with prime factorization. The Euclidean method repeatedly replaces the larger number with the remainder until the remainder is zero, while the factorization method compares the prime powers shared by every input.

The calculator also shows the related LCM, checks whether the inputs are coprime, and provides Bézout coefficients for the two-number case. That gives you both the answer and the structure behind it. It is useful when you want to move from a simple shared-factor question into the broader number-theory relationships around the same inputs. That extra context is what makes the result more than a single classroom vocabulary word.

When This Page Helps

GCD appears anywhere shared divisibility matters: fraction reduction, modular arithmetic, solving linear combinations, and checking coprimality. This calculator is useful because it exposes both the Euclidean path and the factorization path, so the result is easy to verify and explain. The extra outputs also make it easier to connect the answer to LCM, Bézout identities, and coprime tests without opening a second tool.

How to Use the Inputs

  1. Enter the integers you want to compare, up to the supported limit.
  2. Choose the method you want to inspect, such as Euclidean algorithm or prime factorization.
  3. Use a preset like 12 and 18 if you want a quick example of a nontrivial GCD.
  4. Read the main GCD result first, then check the step table or factor view to see how it was built.
  5. Use the Bézout and LCM outputs when you need the number-theory context around the GCD.
  6. Change one input at a time if you are comparing how the GCD shifts across similar number sets.
Formula used
Euclidean: gcd(a, b) = gcd(b, a mod b); base case gcd(a, 0) = a. Prime factorization: gcd = ∏ p^min(e₁, e₂) over shared primes.

Example Calculation

Result: The GCD of 48 and 36 is 12.

48 = 36 × 1 + 12, and 36 = 12 × 3 + 0, so the last nonzero remainder is 12.

Tips & Best Practices

  • The last nonzero remainder in the Euclidean algorithm is the GCD.
  • For two numbers, the GCD is always at most the smaller input.
  • Prime factorization is slower, but it makes the shared structure visible.
  • If the GCD is 1, the inputs are coprime.

Euclidean Algorithm In Practice

The Euclidean algorithm is the standard fast method for computing gcd(a, b). Instead of listing all factors, it repeatedly replaces the larger number with the remainder after division. When the remainder reaches zero, the last nonzero remainder is the GCD. This is why the method remains efficient even for large integers, and why it is the version most often used in programming and computer algebra systems.

Prime Factorization View

The factorization table is slower for large numbers, but it is excellent for understanding why the answer is what it is. By comparing prime exponents across the inputs and taking the minimum exponent for each shared prime, you can reconstruct the GCD directly. That makes the calculator useful for instruction, especially when learners are transitioning from factor trees to algorithmic methods.

Bézout Coefficients And Coprimality

For two inputs, the extended Euclidean algorithm produces integers x and y such that ax + by = gcd(a, b). Those coefficients matter in modular inverses and Diophantine equations. The coprime check is equally important: when the GCD is 1, the numbers share no nontrivial factor, which is a foundational condition in many number-theory and cryptographic problems.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • The GCD of two or more integers is the largest positive integer that divides all of them without a remainder. For example, GCD(12, 18) = 6.