How to use the GCF and LCM calculator
- Type two or more whole numbers, separated by commas or spaces. You can enter up to 50 numbers of up to 30 digits each.
- The greatest common factor and least common multiple appear as you type, with Euclid’s algorithm, the prime factors and, for small numbers, the lists of factors and multiples.
- For two numbers you also get the fraction in lowest terms and the Bézout identity.
What the greatest common factor is
A factor (or divisor) of a number divides it with no remainder. Two numbers usually share several factors, and the largest one is the one of interest. OpenStax’s Contemporary Mathematics explains: “This divisor is called the greatest common divisor and is denoted GCD. It is also sometimes referred to as the greatest common factor (GCF).” Another name for it is the highest common factor (HCF). For 54 and 36 the answer is 18: as OpenStax’s Elementary Algebra puts it, “54 and 36 can be written as multiples of 18.”
What the least common multiple is
A multiple of a number is that number times a whole number: the multiples of 12 are 12, 24, 36, 48 and so on. The least common multiple is the smallest number that is a multiple of every number in the set. For 12 and 18, the multiples of 18 are 18, 36, 54, …, and the first one that 12 also divides is 36, so the LCM is 36. You need the LCM whenever you add or subtract fractions with different denominators, because it is the least common denominator.
Method 1: listing factors and multiples
For small numbers, list every factor of each number and pick the largest one they share. OpenStax works through 1,400 and 250 this way: “The divisors of 250 are 1, 2, 5, 10, 25, 50, 125, 250,” and the largest value on both lists is 50. Listing is easy to follow but slow for big numbers, so the calculator shows the lists only for up to six numbers of up to 10,000.
Method 2: prime factors
Write each number as a product of primes. The GCF uses only the primes that appear in every number, each to the smallest power it has in any of them. The LCM uses every prime that appears in any number, each to the largest power. For 1,400 = 2³ × 5² × 7 and 250 = 2 × 5³, the shared primes are 2 and 5, so the GCF is 2 × 5² = 50, and the LCM is 2³ × 5³ × 7 = 7,000. OpenStax’s Prealgebra uses the same idea for the LCM of 12 = 2 · 2 · 3 and 18 = 2 · 3 · 3: “By matching up the common primes, each common prime factor is used only once,” giving 2 · 2 · 3 · 3 = 36.
Method 3: Euclid’s algorithm
Euclid described a faster way more than 2,000 years ago, in Book VII of the Elements: “To find the greatest common measure of two given numbers not relatively prime.” Divide the larger number by the smaller and keep the remainder; then divide the smaller number by that remainder, and repeat until the remainder is 0. The last nonzero remainder is the GCF. D. E. Joyce’s notes on the Elements work through 884 and 3,009: the remainders are 357, 170 and 17, and “17 divides 170,” so the GCF is 17. The calculator shows each step:
3,009 = 3 × 884 + 357; 884 = 2 × 357 + 170; 357 = 2 × 170 + 17; 170 = 10 × 17 + 0. The last nonzero remainder is 17.
Euclid’s algorithm needs no prime factors, so it stays fast even for 30-digit numbers whose prime factors would take a long time to find.
GCF × LCM = the product of two numbers
For two numbers, the GCF and LCM are linked: their product equals the product of the two numbers. So once you have the GCF from Euclid’s algorithm, the LCM is a × b ÷ GCF. For 884 and 3,009: 17 × 156,468 = 2,659,956 = 884 × 3,009. This shortcut works only for two numbers at a time; for more, the calculator applies it pair by pair.
More than two numbers
The GCF of three or more numbers is found two at a time: GCF(a, b, c) = GCF(GCF(a, b), c), and the same goes for the LCM. For 8, 12 and 20, GCF(8, 12) = 4 and GCF(4, 20) = 4, so the GCF is 4; the LCM is 120.
Coprime numbers and the Bézout identity
Numbers whose GCF is 1 are called coprime, or relatively prime. 8 and 15 are coprime even though neither is prime. Running Euclid’s algorithm backwards also gives whole numbers x and y with a × x + b × y = GCF(a, b), known as the Bézout identity. For 884 and 3,009 the calculator finds 884 × (−17) + 3,009 × 5 = 17. This is how modular inverses are found in number theory and cryptography.
Everyday uses
Simplifying a fraction means dividing the top and bottom by their GCF: 884/3,009 becomes 52/177. Adding fractions needs a common denominator, and the LCM is the smallest one. The LCM also answers timing questions: if one bus comes every 12 minutes and another every 18 minutes, and they leave together, they next leave together after 36 minutes. The GCF answers sharing questions: 54 apples and 36 oranges can be packed into at most 18 identical bags with nothing left over.
Your data stays on your device
Everything is worked out in your browser. Nothing you type is sent anywhere or stored.
Frequently asked questions
Are GCF, GCD and HCF the same thing?
Yes. The greatest common factor, greatest common divisor and highest common factor are three names for the largest whole number that divides every number in the set.
How many numbers can I enter?
Up to 50 whole numbers, each up to 30 digits, separated by commas, spaces or new lines. The GCF and LCM are always exact.
What does it mean when the GCF is 1?
The numbers are coprime (relatively prime): they share no factor except 1. Their LCM is then their product, for two numbers.
How do I use the GCF to simplify a fraction?
Divide the top and bottom by their GCF. Enter the numerator and denominator, and the calculator shows the fraction in lowest terms.
Can I use negative numbers or zero?
This calculator takes whole numbers from 1. For negative numbers, use their absolute values: the GCF and LCM are usually given as positive numbers.
Is my data uploaded?
No. Everything is worked out in your browser and nothing you type is sent anywhere or stored.