Greatest Common Divisor (GCD) Calculator
Enter two or more whole numbers separated by commas to find their greatest common divisor (GCD). Also called the greatest common factor (GCF) or highest common factor (HCF), the GCD is the largest positive integer that divides every number in your list without a remainder. Choose your preferred method (Euclidean algorithm, prime factorization, or factor listing) and follow the step-by-step working below the result.
Formula
Worked example
Find GCD(48, 180). Euclidean: 180 = 48 x 3 + 36; 48 = 36 x 1 + 12; 36 = 12 x 3 + 0. Last non-zero remainder is 12, so GCD = 12. Check via prime factorization: 48 = 2^4 x 3; 180 = 2^2 x 3^2 x 5. Common primes with lowest exponents: 2^2 x 3^1 = 4 x 3 = 12. Confirmed.
What is the greatest common divisor?
The greatest common divisor (GCD) of two or more integers is the largest positive integer that divides each of them without leaving a remainder. It is also called the greatest common factor (GCF) or highest common factor (HCF). For example, GCD(48, 180) = 12 because 12 is the largest number that divides both 48 and 180 exactly. GCD has a special case: GCD(k, 0) = k for any non-negative integer k, and GCD(0, 0) is undefined. If the GCD of two numbers is 1, the numbers are called coprime or relatively prime, meaning they share no common factor other than 1.
Three ways to calculate GCD
The Euclidean algorithm is the fastest method for large numbers. You divide the larger number by the smaller, note the remainder, then repeat with the smaller number and the remainder. When the remainder reaches zero, the last non-zero remainder is the GCD. Example: GCD(48, 180) - 180 divided by 48 leaves 36; 48 divided by 36 leaves 12; 36 divided by 12 leaves 0, so GCD = 12. The prime factorization method factors each number into primes, then multiplies together the smallest exponent of each prime that appears in every factorization. The factor-listing method lists every divisor of each number, identifies the factors appearing in all lists, and picks the largest. All three methods yield the same answer.
GCD and LCM: linked by a simple identity
The least common multiple (LCM) is the smallest positive integer divisible by every number in your list. GCD and LCM are connected by the identity: GCD(a, b) x LCM(a, b) = a x b. This means once you know the GCD you can find the LCM instantly: LCM(a, b) = a x b / GCD(a, b). For example, LCM(48, 180) = 48 x 180 / 12 = 8640 / 12 = 720. For more than two numbers, the relationship extends step by step: find GCD or LCM for the first pair, then bring in each additional number one at a time.
Practical uses of GCD
Simplifying fractions is the most common everyday use: divide numerator and denominator by their GCD to reach lowest terms. For instance, 48/180 simplifies to 4/15 because dividing both by GCD(48, 180) = 12 gives 4/15. GCD also appears in scheduling (when two repeating events next coincide), tiling problems (finding the largest square tile that fits a rectangular floor without cutting), gear ratios, dividing resources evenly, and cryptography (the RSA algorithm relies on properties of coprimality). In computer science, the Euclidean algorithm is one of the oldest algorithms still in widespread use.
GCD methods at a glance
| Method | How it works | Best for |
|---|---|---|
| Euclidean algorithm | Repeatedly replace the larger number with the remainder of dividing by the smaller, until zero | Large numbers, fastest computation |
| Prime factorization | Factor each number into primes, then multiply the lowest power of each prime that appears in all factorizations | Learning prime factors alongside GCD |
| List of factors | List every divisor of each number, identify those appearing in all lists, take the largest | Small numbers, classroom demonstrations |
All three methods always produce the same result. Choose based on what you want to learn.
Frequently asked questions
What is the difference between GCD, GCF, and HCF?
They are all the same thing. Greatest Common Divisor (GCD), Greatest Common Factor (GCF), and Highest Common Factor (HCF) all refer to the largest positive integer that divides two or more numbers without a remainder. The terminology varies by country and curriculum: GCF and HCF are more common in school contexts, while GCD is standard in mathematics and computer science.
What does a GCD of 1 mean?
A GCD of 1 means the numbers are coprime, or relatively prime. They share no common factor other than 1. This does not mean the numbers themselves are prime - for example, GCD(8, 9) = 1, but neither 8 nor 9 is prime. Coprimality is important in fraction simplification (the fraction is already in lowest terms) and in modular arithmetic and cryptography.
How do I find the GCD of more than two numbers?
Apply GCD pairwise and carry the result forward. GCD(a, b, c) = GCD(GCD(a, b), c). For example, GCD(12, 18, 24): GCD(12, 18) = 6, then GCD(6, 24) = 6. This calculator does that automatically for up to 10 numbers.
What is GCD(0, n)?
GCD(0, n) = n for any positive integer n, because every integer divides 0 (0 = n x 0), so the largest divisor shared by 0 and n is n itself. GCD(0, 0) is undefined because there is no largest integer dividing 0.
How is GCD related to simplifying fractions?
To simplify a fraction a/b to lowest terms, divide both the numerator and denominator by GCD(a, b). The result is an equivalent fraction where the numerator and denominator are coprime. For example, 48/180: GCD(48, 180) = 12, so 48/12 = 4 and 180/12 = 15, giving 4/15 in lowest terms.
Why is the Euclidean algorithm so fast?
Each step of the Euclidean algorithm reduces at least one of the two numbers by at least half, so the number of steps is proportional to the number of digits (specifically, at most about 5 times the number of decimal digits of the smaller number). For very large numbers this is dramatically faster than factoring them or listing all their divisors.