Calculate the Greatest Common Factor of two or more numbers with prime factorization steps.
Reviewed by the CalculatorKosh Editorial TeamUpdated June 2026Free ยท No sign-up
GCF Calculator
Calculate the Greatest Common Factor of two or more numbers with prime factorization steps.
How It Works
The Greatest Common Factor (GCF) โ also called the Greatest Common Divisor (GCD) or Highest Common Factor (HCF), the term most Indian school textbooks use โ is the largest positive integer that divides two or more whole numbers without leaving a remainder. This calculator takes two positive integers and instantly returns their GCF along with the Least Common Multiple (LCM), the complete list of factors of each number, and the factors they share in common. It is built for students working through CBSE, ICSE and state-board arithmetic, for anyone simplifying fractions or ratios, and for developers and hobbyists who need a quick, accurate divisor check without reaching for a programming language.
The GCF and LCM are two sides of the same idea and are bound together by a clean identity: GCF(a, b) ร LCM(a, b) = a ร b. Knowing one immediately gives you the other. These quantities sit at the heart of number theory and show up far beyond the classroom โ in reducing fractions to lowest terms, finding common denominators, scaling recipes, gear and pulley ratios, scheduling repeating events, and in cryptography where two numbers being coprime (GCF = 1) is a foundational property.
How the GCF is calculated
There are two standard methods, and both give the same answer. The first is prime factorisation: break each number into its prime factors, then multiply together every prime they share, using the lowest power that appears in either number. For example, 12 = 2ยฒ ร 3 and 18 = 2 ร 3ยฒ. The shared primes are 2 (lowest power 2ยน) and 3 (lowest power 3ยน), so the GCF = 2 ร 3 = 6.
The second โ and far faster for large numbers โ is the Euclidean algorithm, one of the oldest algorithms still in everyday use. It repeatedly applies the rule GCD(a, b) = GCD(b, a mod b), replacing the larger number with the remainder of dividing the larger by the smaller, and stops when the remainder reaches 0. The last non-zero divisor is the GCF. This calculator uses the Euclidean method internally because it stays fast even when the inputs run into millions, while still displaying the full factor lists so you can see the shared factors for yourself.
LCM formula
LCM(a, b) = |a ร b| / GCF(a, b)
Worked example
Suppose you want the GCF and LCM of 48 and 18. Using the Euclidean algorithm: GCD(48, 18) โ 48 mod 18 = 12, so GCD(18, 12) โ 18 mod 12 = 6, so GCD(12, 6) โ 12 mod 6 = 0. The last non-zero divisor is 6, so GCF(48, 18) = 6. Plugging into the LCM formula: LCM = (48 ร 18) / 6 = 864 / 6 = 144. You can sanity-check the identity: GCF ร LCM = 6 ร 144 = 864, which equals 48 ร 18. The factor lists confirm it too โ the factors common to both 48 and 18 are 1, 2, 3 and 6, and the greatest of those is 6.
Tips for using this calculator
- To simplify a fraction, enter the numerator and denominator, then divide both by the GCF. For 18/48, the GCF is 6, giving the reduced fraction 3/8.
- To add or subtract fractions with different denominators, use the LCM as the common denominator โ it keeps the numbers as small as possible.
- For three or more numbers, work in pairs: GCF(a, b, c) = GCF(GCF(a, b), c). Run the first pair, then feed the answer back in with the next number.
- If the GCF comes back as 1, the two numbers are coprime and the fraction is already in lowest terms.
Common mistakes to avoid
- Confusing GCF with LCM. The GCF is always less than or equal to the smaller number; the LCM is always greater than or equal to the larger number. If your answer breaks that rule, you have swapped them.
- Taking the highest power instead of the lowest when using prime factorisation. The GCF uses the lowest shared power of each common prime; using the highest power gives the LCM instead.
- Forgetting 1 is always a common factor. Every pair of positive integers shares the factor 1, which is why the GCF is never zero.
- Using non-positive or non-integer inputs. GCF and LCM are defined for positive whole numbers; decimals or zero do not have a meaningful greatest common factor here.
Frequently Asked Questions
The GCF (Greatest Common Factor) is the largest number that divides both values evenly. It is used to simplify fractions to lowest terms โ divide both numerator and denominator by their GCF. For example, 12/18 โ GCF is 6 โ simplified to 2/3.
Part of Algebra & Numbers Calculators โ compare every related calculator in one place.