GCD Calculator
Calculate the Greatest Common Divisor (GCD) of two or more numbers using the Euclidean algorithm. Instant result.
What is GCD?
We call the Greatest Common Divisor (GCD) the largest number that divides two or more integers exactly. To find it, use the Euclidean algorithm: divide the larger by the smaller, then redo the operation with the divisor and the remainder until that remainder reaches zero.
Here is an example. GCD(12, 8) → 12 = 1×8 + 4 → 8 = 2×4 + 0 → GCD = 4.
Greatest common divisor and the Euclidean algorithm
The greatest common divisor gcd(a, b) is the largest positive integer that divides both a and b with zero remainder. The Euclidean algorithm computes it efficiently using the identity gcd(a, b) = gcd(b, a mod b), repeated until b = 0 — at which point the answer is a. Example: gcd(48, 18) → gcd(18, 12) → gcd(12, 6) → gcd(6, 0) = 6. The procedure dates back to Euclid's Elements (Book VII, c. 300 BC) and runs in O(log min(a, b)) — dramatically faster than trial-factoring both numbers, which is O(sqrt n).
A useful identity links GCD and LCM: a · b = gcd(a, b) · lcm(a, b). Two integers are coprime when their GCD equals 1.
Where the GCD shows up
- Reducing fractions to lowest terms:
18/48 = 3/8after dividing both by gcd = 6. - RSA cryptography uses the extended Euclidean algorithm to compute modular inverses of the public exponent.
- Partitioning quantities into equal groups (e.g., the largest tile size that paves a rectangular floor without cuts).
- Diophantine equations
ax + by = chave integer solutions iffgcd(a, b) | c.
FAQ
Why prefer Euclid over factoring both numbers? Euclid runs in O(log min(a, b)); trial-division factoring is O(sqrt n). For 20-digit numbers Euclid finishes in microseconds while factoring may take seconds or minutes.
What is gcd(0, n)? By convention gcd(0, n) = n for any positive n, since every integer divides 0.
How does GCD scale to more than two numbers? Apply pairwise: gcd(a, b, c) = gcd(gcd(a, b), c). The operation is associative.
Can the GCD be negative? No — by definition the GCD is the largest positive divisor. Negative signs in inputs are dropped.
Calculate the GCD (greatest common divisor)
The greatest common divisor is the largest number that divides two or more values at the same time. It shows up as the basis for simplifying fractions and in plenty of maths problems. This calculator reaches the GCD through Euclid's algorithm, which is efficient and exact.
Enter two or more numbers and the GCD comes out next. It works for reducing fractions to lowest terms, splitting quantities into equal groups, solving school exercises or any situation where you need the largest common factor between the values.
Instead of doing the decomposition on paper, the calculation runs straight in the browser. A quick reference for one of arithmetic's most basic operations.
Related Tools
GCD Calculator (Euclidean Algorithm)
Returns the greatest common divisor of two integers through repeated remainder division, the Euclidean algorithm. Signs are ignored and decimals truncated.
Maximum Bending Moment Beam
Computes maximum bending moment for a simply supported beam (UDL or central point load).
PT Short Story Word Count
Estimates typical word count for common short story in Portuguese by subgenre.
Series Resistor Voltage Divider Calculator
Computes the voltage across each resistor in a series voltage divider from the input voltage and R1, R2 values.
Parallel Current Divider Calculator
Computes the current in each branch of a parallel current divider from the total current and two resistances.
VO2 Max Cooper Test
Estimates VO2 max (mL/kg/min) from distance covered in the 12-minute Cooper test.
The results provided by this tool are for general informational and educational purposes only and do not constitute professional, financial, medical, legal, tax or accounting advice. Always confirm important decisions with a qualified professional and official sources.