GCF/GCD Calculator
Calculate the Greatest Common Factor (GCF) or Greatest Common Divisor (GCD) of two or more numbers. Uses the Euclidean algorithm with step-by-step explanation.
About this calculator
This calculator finds the Greatest Common Factor of two to four numbers using the Euclidean algorithm (lines 11-38, repeated subtraction of remainders rather than factorization). First Number and Second Number are required; Third Number and Fourth Number default to 0 and are structurally excluded from the working list whenever they're 0 (line 110-111 only adds them when nonzero) — so with the defaults unchanged, the algorithm runs on First Number and Second Number alone, and only folds in a third or fourth value once one of those optional fields is set to something nonzero. GCF is a genuinely chaotic function of its inputs, not a smooth one: at the defaults (48, 36), the GCF is 12, but nudging Second Number by 10% lands on 32 (floor of 32.4) on the low side and 39 (floor of 39.6) on the high side, and GCD(48, 32) is 16 while GCD(48, 39) is only 3 — the GCF actually falls as Second Number rises through this range, the opposite of a "bigger numbers, bigger factor" intuition, because what matters is which prime factors the two numbers happen to share, not their size.
Are Numbers Coprime? (line 190) is simply a check for whether GCF equals exactly 1; it is not computed independently. This calculator does not accept 0 as a meaningful value for any of the four number fields (line 114-115 treats any included 0 as invalid and skips the algorithm entirely), and it floors all inputs to integers (line 103-106) without validating that they're positive.
Inputs
Results
Greatest Common Factor (GCF)
12
How to Use This Calculator
- Enter two required numbers and up to two optional additional numbers in the Number fields.
- The Greatest Common Factor (GCF/GCD) is the largest integer that divides all entered numbers evenly, computed via the Euclidean algorithm.
- Are Coprime? indicates whether the GCF equals 1 — coprime numbers share no common factors other than 1.
- The Least Common Multiple is also computed: LCM = (n1 × n2) / GCF — useful for adding fractions with different denominators.
- All Common Divisors lists every shared factor, giving insight into divisibility relationships.
- Use positive integers only; the algorithm is undefined for zero or negative inputs.
Recommended for this calculation
We may earn a commission if you sign up through these links.
Graph, solve, and visualize every statistics problem
TI-84 Plus CE Graphing Calculator, Color Screen
See on AmazonWork through problems the way they're meant to be graphed
Mr. Pen Graph Grid Journal Notebook, A5, 160 Pages
See on Amazon417 functions for every equation you'll ever face
Casio fx-991ES Plus 2 Scientific Calculator
See on AmazonTexas Instruments: As an Amazon Associate I earn from qualifying purchases.
Mr. Pen: As an Amazon Associate I earn from qualifying purchases.
Casio: As an Amazon Associate I earn from qualifying purchases.
How the result changes with Second Number
| Second Number | Greatest Common Factor (GCF) |
|---|---|
| 100,000,001 | 1 |
| 350,000,000 | 16 |
| 650,000,000 | 16 |
| 899,999,999 | 1 |
What each input means
- First Number
- First number.
- Second Number
- Second number.
- Third Number (Optional)
- Leave as 0 if not needed
How this is calculated
Formula
GCD(a, b) = GCD(b, a mod b)Engine last updated . Checked against 1 independently-derived test — how we verify calculators.
Frequently Asked Questions
Does adding a Third Number or Fourth Number of 0 change the GCF calculation?
No — a Third Number or Fourth Number left at its default of 0 is never added to the working list of numbers (line 110-111 only pushes it on when it's nonzero), so the Greatest Common Factor is computed from First Number and Second Number alone via the Euclidean algorithm, exactly as if the two optional fields weren't there.
If I raise Second Number, does the Greatest Common Factor always go up too?
No — at the defaults (48, 36), raising Second Number from its −10% probe value of 32 up to its +10% probe value of 39 actually lowers the GCF, from 16 down to 3, because GCD(48, 32) = 16 while GCD(48, 39) = 3. The Euclidean algorithm depends on which prime factors the two numbers share, not on how large either one is, so there's no steady "raising the input raises the output" trend to state for GCF.
How does 'Are Numbers Coprime?' get determined?
It's a direct check on the already-computed GCF, not a separate calculation: line 190 asks whether the Greatest Common Factor equals exactly 1, since two or more numbers are coprime by definition when they share no common factor besides 1. At the defaults (48, 36, GCF 12) the numbers are not coprime.
What happens if one of the required numbers is set to 0?
The calculator does not run the Euclidean algorithm against a 0. The guard at line 114-115 detects any included 0 among the numbers and returns "GCF requires all non-zero numbers" along with a Greatest Common Factor of 0, rather than attempting a division that the algorithm can't meaningfully perform.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
LCM Calculator
Calculate the Least Common Multiple (LCM) of two or more numbers. Uses prime factorization to find the smallest number that is a multiple of all inputs.
Math & StatisticsPrime Factorization Calculator
Find the prime factorization of any number. Shows all prime factors, divisors, and whether the number is prime, perfect, abundant, or deficient.
Math & StatisticsPercentage Calculator
Calculate percentages easily — find a percentage of a number, percentage increase/decrease, and percentage change between two values.
More in Math & Statistics.