GCD Calculator
Calculate the Greatest Common Divisor (also called HCF or GCF) using the Euclidean algorithm, prime factorisation, or a repeated-division ladder with full step-by-step solutions.
Enter numbers to find the GCD
Accepts comma, space, semicolon, or newline-separated positive whole numbers up to 1,000,000,000,000.
What is the GCD Calculator?
The Greatest Common Divisor (GCD) — also known as the Highest Common Factor (HCF) or Greatest Common Factor (GCF) — is the largest positive integer that divides every input cleanly. It is the natural answer to questions like 'What is the largest equal share I can make?' or 'What is the simplest form of this ratio?'
This GCD calculator factors each input by trial division, intersects the prime factorisations using the lowest shared exponent, and shows the full Euclidean-algorithm derivation side-by-side. You get the GCD, the list of every common divisor, the prime-factor table, and a step-by-step solution in three independent methods — Prime Factorisation, Euclidean Algorithm, and the Repeated-Division Ladder.
How the GCD Calculator works
Method 1 — Prime factorisation
Factor every input. For each prime that appears in EVERY input, take the LOWEST exponent. Multiply the result to get the GCD.
Method 2 — Euclidean algorithm
Repeatedly replace the larger number by the remainder of dividing it by the smaller. The last non-zero remainder is the GCD. Runs in O(log min(a, b)) steps.
Method 3 — Repeated-division ladder
Stack the inputs in a row. Divide them all by the smallest prime that divides every one. Repeat. When no prime divides every value, multiply the divisors used — that product is the GCD.
Cross-check via the identity
Once you know GCD, LCM × GCD = a × b confirms the value for two-input cases. The calculator runs this check automatically and flags any inconsistency.
GCD formula library
Euclidean algorithm
gcd(a, b) = gcd(b, a mod b)
Replace the larger by the remainder. Terminates in O(log min(a, b)) steps.
LCM × GCD identity
LCM(a, b) × GCD(a, b) = a × b
True for any pair of positive integers. Use it to read one off the other in constant time.
Prime-factor GCD
GCD = p₁^min(e) × p₂^min(e) × …
Take the LOWEST exponent of each prime that appears in EVERY input.
Coprime check
coprime ⟺ gcd(a, b) = 1
Two integers are coprime exactly when their GCD is 1.
When to use the GCD calculator
Simplifying fractions
Divide numerator and denominator by their GCD. The result is in lowest terms in one step.
Reducing ratios
Aspect ratios, recipe scaling, and screen resolutions all reduce by the GCD. 1920 × 1080 simplifies to 16 : 9 because GCD(1920, 1080) = 120.
Modular arithmetic
The modular inverse a⁻¹ mod n exists exactly when gcd(a, n) = 1. The extended Euclidean algorithm computes the inverse in the same number of steps as the plain GCD.
Splitting into equal groups
When you must split multiple quantities into groups of equal size, the LARGEST group size that works is the GCD of the quantities.
Why GCD matters
Euclid's algorithm for the GCD, written down ~300 BC, is the oldest non-trivial algorithm in continuous use. Every modern cryptography library executes some variation of it billions of times a day — for example, every time an RSA public key is generated, GCD is used to verify that the chosen exponent is coprime to the totient of the modulus.
Outside cryptography, GCD shows up wherever 'common factor' is a concept: simplifying fractions, reducing ratios in design and music, normalising sampling rates in audio software, and computing cycle lengths in deterministic finite automata. The classroom and the data centre rely on the same compact recursion.
Frequently Asked Questions
Related Calculators
More number-theory and fraction tools that pair with GCD work.
- LCM CalculatorLeast Common Multiple of any list of integers with prime-factor and ladder methods, step-by-step working, and charts.
- Common Factor CalculatorGreatest common factor (GCF, HCF, GCD) with step-by-step prime factorization.
- Prime Factorization CalculatorPrime factors with a visual factor tree and step-by-step working.
- Fraction CalculatorAdd, subtract, multiply, divide, simplify, and convert fractions with step-by-step solutions.
- Ratio CalculatorSimplify, scale, and compare ratios; solve equivalent ratios and proportions.
- Scientific CalculatorAdvanced trig, log, exponent, root, factorial, and memory functions.