Mathematics · Numbers and arithmetic
Find the greatest common factor of integers
Enter at least two integers. The result is the largest positive integer that divides all of them — the same GCF used to reduce a fraction or a ratio.
Calculate
How the calculator works
Values are read as integers. Euclid’s algorithm computes the GCF of the first pair, then the GCF of that result with the next number, and so on. Signs are ignored (GCF(−12, 18) = 6). A list of all zeros is rejected.
Formula and method
GCF(a, b) = GCF(b, a mod b) until the remainder is 0
Euclid, Elements Book VII: replace the larger number by the remainder. GCF(48, 18) → GCF(18, 12) → GCF(12, 6) → GCF(6, 0) = 6.
GCF(a, b, c) = GCF(GCF(a, b), c)
12, 18, 24: GCF(12, 18) = 6, then GCF(6, 24) = 6.
Each token must be an integer (not 12.5). At least two numbers. GCF(0, n) = |n| for n ≠ 0; GCF(0, 0) is not defined here. US classrooms often say GCF; the same function is GCD in programming.
Worked example
12, 18, and 24
12 ; 18 ; 24
- GCF(12, 18): 18 = 1×12 + 6, 12 = 2×6 + 0, so 6.
- GCF(6, 24) = 6.
GCF = 6 (6 divides 12, 18, and 24; 12 does not divide 18).
Input notes
- Integers
- List of integers (≥ 2). Decimals are refused. Isolated zeros are allowed if a nonzero remains.
Assumptions and limits
Assumptions
- You want a common divisor in the integers, not a polynomial GCF.
- Order of the numbers does not change the result.
Limits
- Prime factorization is not listed, only the GCF.
- Very large integers share JavaScript’s integer precision limits.
How to read the result
6 is the largest bundle size that splits 12, 18, and 24 with no remainder. For 18/24, divide both by 6 to get 3/4. The LCM of the same three numbers is a different integer.
Common mistakes
Reporting a common factor that is not the greatest (2 instead of 6).
2 divides all three, but 6 is larger and still divides all three.
Confusing GCF with LCM.
GCF is a divisor. LCM is a multiple. For 12 and 18, GCF is 6 and LCM is 36.
Related calculations
- LCMEnter at least two nonzero integers. The result is the smallest positive integer that is a multiple of each — useful for common denominators and repeating schedules.
- FractionsTwo integer fractions and an operation. The engine uses a common denominator or cross-products, then reduces by the GCF so the answer is in lowest terms.
- RatioTwo integers in, a reduced ratio out (8 : 12 becomes 2 : 3), plus the quotient A/B and each term’s weight in the sum of absolute values — not “A as a percent of B.”
- ExponentEvaluate aᵇ. Integers, decimals, negative exponents (reciprocals), and 1/2 (square root, base ≥ 0) are possible, within the reals and floating-point limits.
- Square rootEnter a number that is not negative. The tool returns the principal (nonnegative) square root. It is the inverse of squaring, not a cube root or an nth root.
- Speed, distance, timeTwo known quantities, the third follows. Kilometres and km/h, or miles and mph, but not a mix of the two systems.
Frequently asked questions
Is GCF the same as GCD?
Yes. Greatest common factor and greatest common divisor name the same integer.
Schools in the US often print GCF. Code and number theory often print gcd. This page computes that value with Euclid’s remainder loop.
What about GCF(0, 12)?
12. GCF(0, 0) is rejected.
Every integer divides 0, so the greatest common divisor of 0 and 12 is 12. Two zeros have no greatest positive common divisor in this tool.
Can I use this to reduce a fraction?
Yes: divide numerator and denominator by their GCF.
The fractions page does that in one step. This page is handy when you have more than two integers to reduce together.
Author and update
Written by Rédaction HexaCalc (editorial team). Content last updated: August 25, 2026. No third-party medical or financial review is claimed.
- Les Éléments, Livre I (théorème de Pythagore) et Livre VII (algorithme d’Euclide) — Tradition mathématique euclidienne
Need the least common multiple instead?
LCM uses this GCF internally: LCM(a, b) = |a × b| / GCF(a, b).
Calculate the LCMCategory: Mathematics