Find the greatest common factor of two to six numbers, with Euclid's algorithm worked line by line, the prime factorization of every input, and the matching LCM alongside.
The greatest common factor (GCF), also called the greatest common divisor (GCD), of two or more whole numbers is the largest number that divides every one of them with no remainder. For 48 and 18, the divisors of 48 are 1, 2, 3, 4, 6, 8, 12, 16, 24 and 48, and the divisors of 18 are 1, 2, 3, 6, 9 and 18. The largest number on both lists is 6, so GCF(48, 18) = 6.
Listing divisors works for small numbers, but it becomes hopeless quickly: 1,000,000,000 has far too many divisors to enumerate. Mathematicians use two better methods, and this calculator shows both: Euclid's algorithm, which is astonishingly fast, and prime factorization, which explains why the answer is what it is.
Recorded in Euclid's Elements around 300 BC, this is one of the oldest algorithms still in daily use. It rests on one observation: any number that divides both a and b also divides their remainder, so the GCF of a and b equals the GCF of b and the remainder of a ÷ b. Repeat until the remainder hits zero, and the last nonzero remainder is the answer:
gcf(a, b) = gcf(b, a mod b)
repeat until the remainder is 0; the last divisor is the GCF
Worked with 48 and 18:
Three lines, even though listing divisors of 48 took ten. The algorithm is dramatically faster on big numbers: the worst case (consecutive Fibonacci numbers) still finishes in a handful of steps, which is why the calculator can handle inputs up to a billion instantly.
Every whole number above 1 factors into primes in exactly one way. Break each number down, take every prime that appears in all the factorizations, and multiply the smallest power of each:
Both methods agree, as they must. Prime factorization is the slower route for big inputs, but it makes the structure visible: you can see exactly which primes the numbers share. This calculator prints the full factorization of every input with the shared primes marked, alongside Euclid's fast answer.
The GCF extends to any count by pairing: compute the GCF of the first two, then the GCF of that result with the third, and so on. For 12, 18 and 30:
Check by prime factorization: 12 = 22 × 3, 18 = 2 × 32, 30 = 2 × 3 × 5. The primes present in all three are 2 and 3, each to the first power, and 2 × 3 = 6. The calculator takes up to six numbers and applies exactly this chaining, showing the running result after each.
When the GCF is 1, the numbers are called coprime (or relatively prime). They share no prime building blocks at all, even though each may be highly composite on its own: 8 = 23 and 15 = 3 × 5 share nothing, so GCF(8, 15) = 1. Consecutive integers are always coprime, and so are two distinct primes.
Coprimality is a useful property, not a failure to find a factor. Fractions in lowest terms have coprime numerator and denominator, and the LCM of coprime numbers is simply their product: lcm(8, 15) = 120.
The greatest common factor is the largest number that divides all your inputs, so it is never bigger than the smallest input. The least common multiple is the smallest number all inputs divide into, so it is never smaller than the largest input. For 48 and 18 they are 6 and 144 respectively, and the two are tied by gcf times lcm equals the product of the inputs.
It means the numbers are coprime: they share no prime factor at all. The inputs 8 and 15 have GCF 1 even though both are composite, because 8 is built from 2s and 15 from 3 and 5. A GCF of 1 also tells you a fraction like 8/15 is already in lowest terms.
Each division at least halves the smaller number, so the number of steps grows with the number of digits, not with the size of the values. Even two numbers near a billion finish in a few dozen divisions, while listing every divisor of a billion would take millions of checks. That efficiency is why the 2,300-year-old algorithm still runs inside modern cryptography libraries.
Divide the numerator and the denominator by their GCF. For 48/18, the GCF is 6, so 48 ÷ 6 = 8 and 18 ÷ 6 = 3, giving 8/3. Because you removed the largest shared factor at once, the result is guaranteed to be in lowest terms, and no further simplification is possible.
Yes. Chain the pairwise result: gcf(a, b, c) = gcf(gcf(a, b), c). For 12, 18 and 30, gcf(12, 18) is 6 and gcf(6, 30) is also 6, so the answer is 6. This calculator accepts up to six numbers and applies the same chaining automatically.
That means the smaller number divides the larger one exactly, and it is the largest such factor. For 12 and 36 the GCF is 12, because 36 is three times 12. It is a useful signal: whenever the GCF equals the smallest input, every number in your set is a multiple of it.
Yes, the two names describe the same number: the largest value dividing all the inputs. GCF is the usual classroom name and GCD is the usual mathematics and programming name. Textbooks also use HCF, highest common factor, in some countries, and it means the same thing again.
No. Every calculation runs in your browser. Nothing is stored or transmitted.