GCF Calculator
Find the GCF, GCD, or HCF of two or more integers, including exact 48-digit values. See Euclidean steps, factor checks, and complete exports. Free, no sign-up.
Enter values to calculate.
Trust summary CVP VERIFIED · CVP protocol 1.0.0-proposed · Core assurance
- Input interpretation
- Enter values to calculate.
- Result
- —
- Assurance
- Core
- Declared partition coverage
- PASS · 8/8 declared partitions (gcf, zero, negative, beyond-safe-integer, multi-input-fold, method-unavailable, xcal, invalid-domain) · Matrix
- Known limitations
- 2–32 signed integers up to48 decimal digits; ignore zeros unless all zero; bounded work and complete output
- Core CVP does not include live graph, viewport, or pointer interaction.
- Model
- GCF/GCD/HCF of two or more integers, with factorization and Euclidean steps and method agreement when listing is feasible.
- Scope
- Integer inputs; negatives treated by absolute value.
- Verification
- Engine tested · Source checked · v1.0.3 · CVP VERIFIED · CVP protocol 1.0.0-proposed · Core assurance· View Manifest · CVP overview · Specification
- Versions
- Calculation 1.0.3 · CVP protocol 1.0.0-proposed · Evidence 2026-10-21.gcf-complete-contract-v4
- Verification revision
- 2026-10-21.gcf-complete-contract-v4 · 3/3 property · digest 9af66f58265f
- Legacy regression
- 20/20 tests · Production surface contract 6/6
- Trust layers
- Verification VERIFIED · Production CURRENT · Overall CVP state: VERIFIED under CVP 1.0.0-proposed
- Reference
- O1 model · O2 expected_values · O2 numerical_behavior
- Interfaces
- PASS · UI (SSR) / REST / MCP
- Supplemental domain review
- Not performed
- Named expert review
- Not performed
- CVP suite
- 10/10 golden · 7/7 CVP boundary · 5/5 invalid · 3/3 property · 1/1 metamorphic · 2/2 cross-interface · 5/5 cross-calculator · 6/6 CVP contract · Manifest
- Sources
- Encyclopedia of Mathematics — Greatest common divisor
- Encyclopedia of Mathematics — Euclidean algorithm
- CalculatorX integer convention
- MIT Mathematics for Computer Science — Chapter 8: Number Theory
- Methods
- Pairwise Euclidean fold (canonical engine)
- Prime-factor GCF (cross-check when every |n| ≤ 1,000,000)
- Factor-list GCF (cross-check when every |n| ≤ 10,000)
- Evidence
- 6 legacy golden · 7 legacy boundary · legacy regression suite · 10/10 oracle-backed golden · 5/5 invalid · Artifact integrity PASS
- Semantic contract
- PASS
Full verification
Formulas
Core equations used by this calculator.
How to use
Enter two or more integers
Separate with commas or spaces (e.g. 8, 12, 20). Negatives use absolute value.
Calculate
Read the GCF plus factor / prime / Euclidean working when the values are small enough to list.
Optional: simplify a fraction
Divide numerator and denominator by their GCF.
Example calculations
Common configurations with formula and result.
Three numbers
8, 12, 20
Prime method
18 and 27
Euclidean
48 and 18
With zero
GCF(5, 0)
Zeros then a nonzero
0, 0, 5
Quick checks
Common values at a glance.
| Numbers | GCF |
|---|---|
| 8, 12, 20 | 4 |
| 18, 27 | 9 |
| 20, 50, 120 | 10 |
| 16, 88, 104 | 8 |
| 32, 256 | 32 |
| 5, 0 | 5 |
| 0, 0, 5 | 5 |
| 0, 0 | undefined |
GCF calculator specification
Version 1.0.3 · Engine tested
- Engine tested 20/20 tests · Production surface contract 6/6
- Named expert review Not performed
- Calculation version 1.0.3
- Definition
- The greatest common factor (GCF), also called GCD or HCF, of a set of integers is the largest positive integer that divides each of them with zero remainder. Enter two or more integers separated by commas or spaces. Negative values are treated by absolute value.
- What it calculates
- GCF/GCD/HCF of two or more integers, with factorization and Euclidean steps and method agreement when listing is feasible.
- Inputs
- Two or more integers (comma- or space-separated). Share-URL field: numsInput. REST aliases: values, numbers.
- Outputs
- Positive GCF (JSON number when it fits IEEE-754 safe integers; otherwise the exact decimal string)
- Factor lists (when every |n| ≤ 10,000)
- Prime factorization view (when every |n| ≤ 1,000,000)
- Euclidean algorithm steps
- Method agreement (factor / prime / Euclidean)
- Formula
GCF(a,b,c,…) = GCF(GCF(a,b),c,…); GCF(a,b)=GCF(b, a mod b)- Assumptions
- Integer inputs; negatives treated by absolute value.
- Zeros are ignored unless every input is 0.
- GCF of a set of all zeros is undefined.
- Units
- Dimensionless (integers)
- Boundary conditions
- Need at least two numbers → NEED_TWO_NUMBERS
- Missing list → MISSING_REQUIRED_INPUT
- Non-integers rejected → INVALID_NUMBER
- More than 48 digits → VALUE_ABOVE_MAX
- All zeros → UNDEFINED
- Numerical precision
- Interactive calculation uses exact BigInt locally: pairwise Euclidean fold, ignoring zeros.
- Shareable URLs (?numsInput=8,12,20) are server-rendered with the same deterministic engine so crawlers and no-JS clients see the same result.
- REST and SSR return { values, value, exact, count, formula, binary_formula, methods, work, max_digits }. value is a JSON number when it fits in IEEE-754 safe integers, otherwise the exact decimal string.
- Integers beyond MAX_SAFE_INTEGER must be sent as decimal strings so JSON number rounding cannot change them.
- The 48-digit cap is a CalculatorX product bound, not a mathematical bound.
- Example
- GCF(8,12,20)=4; GCF(0,0,5)=5; GCF(9007199254740993, 3)=3
- Validation cases
7 published on this page · 20/20 tests · Production surface contract 6/6 · View evidence
- 8, 12, 20 → 4
- 18, 27 → 9
- 20, 50, 120 → 10
- 5, 0 → 5
- 0, 0, 5 → 5
- 0, 0 → error UNDEFINED
- 9007199254740993, 3 → 3
- Methods
- Pairwise Euclidean fold (canonical engine)
- Prime-factor GCF (cross-check when every |n| ≤ 1,000,000)
- Factor-list GCF (cross-check when every |n| ≤ 10,000)
- Sources
- Encyclopedia of Mathematics — Greatest common divisor — Definition; pairwise fold; prime-factor formSupports: GCF of n integers exists when not all are zero; (a₁,…,aₙ,aₙ₊₁)=((a₁,…,aₙ),aₙ₊₁); shared-prime min exponents
- Encyclopedia of Mathematics — Euclidean algorithm — Remainder recurrence GCF(a,b)=GCF(b, a mod b)Supports: Binary Euclidean primitive used inside the pairwise fold
- CalculatorX integer convention — Absolute value; zero-set; 48-digit BigInt domainSupports: Negatives by |n|; ignore zeros unless the whole set is 0; exact BigInt with a product digit cap
- MIT Mathematics for Computer Science — Chapter 8: Number Theory — Chapter 8, including sections 8.2–8.9 and problem 8.24Supports: Divisibility, prime factorization, gcd and the Euclidean algorithm, lcm via prime exponents, division with remainder, modular congruence and multiplicative inverses. CalculatorX’s signed-remainder and zero-input policies are stated separately on the page. Mathematical reference only; not validation or endorsement of this implementation.
- Encyclopedia of Mathematics — Greatest common divisor — Definition; pairwise fold; prime-factor form
- Calculation version
- 1.0.3
Background
Interpretation and common distinctions.
What does this gcf calculator compute?
The greatest common factor (GCF), also called GCD or HCF, of a set of integers is the largest positive integer that divides each of them with zero remainder. Enter two or more integers separated by commas or spaces. Negative values are treated by absolute value.
The published formula or method is GCF(a,b,c,…) = GCF(GCF(a,b),c,…); GCF(a,b)=GCF(b, a mod b). The following references support the stated mathematics or method:
- MIT Mathematics for Computer Science — Chapter 8: Number Theory: Divisibility, prime factorization, gcd and the Euclidean algorithm, lcm via prime exponents, division with remainder, modular congruence and multiplicative inverses. CalculatorX’s signed-remainder and zero-input policies are stated separately on the page. Mathematical reference only; not validation or endorsement of this implementation.
Which inputs and limits should you check?
Follow the input domain, units, branch or solve direction, and rounding policy in the specification. Preserve exact outputs and any additional candidates or warnings.
The worked example uses 8, 12, 20 with common factors → 4. Compare it with the Example calculations and the complete result for the same inputs.
How can you verify and cite this result?
CalculatorX is responsible for this page. The mathematical references above explain the model; implementation checks and their scope are documented separately in the math.gcf v1.0.3 Evidence and capability contract. Read the displayed verification and production state together with the specification's numerical limits.
Use the clean calculator URL to cite the tool. A shared input link identifies a particular calculation. Content updates, numerical verification, and domain reviews have separate dates and scopes.
What is the GCF?
The greatest common factor (also GCD or HCF) of a set of integers is the largest positive integer that divides each of them with zero remainder.
Example: for 18, 30, and 42, GCF=6.
GCF(a,b,c,…)=GCF(GCF(a,b),c,…)
Negative inputs use absolute value. The result is always a non-negative integer (or undefined when every input is 0).
Methods
Factoring
List positive factors of each nonzero number; the GCF is the largest number common to every list.
18 and 27: factors of 18 are 1, 2, 3, 6, 9, 18; of 27 are 1, 3, 9, 27 → common 1, 3, 9 → GCF = 9.
Prime factorization
Write each nonzero number as a product of primes. Multiply the primes that appear in all factorizations, using the minimum shared count of each prime.
18 = 2×3×3, 27 = 3×3×3 → shared 3×3 → 9.
20, 50, 120 → shared 2×5 → 10.
Euclidean algorithm
Efficient for large values. For a ≥ b > 0:
GCF(a,b)=GCF(b, a bmod b)
until the remainder is 0; the last nonzero remainder is the GCF. More than two numbers use the pairwise fold above.
When the values are small enough to list, the page shows all three methods and reports whether they agree.
GCF and zero
- GCF(k,0)=|k| for k ≠ 0 (every nonzero k divides 0).
- Zeros in a larger set are ignored: GCF(0,0,5)=5.
- A set that is entirely zeros is undefined.
Integer range
Calculation uses exact BigInt, so integers larger than Number.MAX_SAFE_INTEGER stay exact. Each input may have at most 48 decimal digits (a product bound, not a mathematical bound). Values beyond the IEEE-754 safe integer range must be sent to the API as decimal strings.
Example: GCF(9007199254740993, 3)=3.
Simplifying fractions
8/12=(8÷4)/(12÷4)=2/3 because GCF(8,12)=4.
Agent / API notes
Capability id: math.gcf · tool id: gcf · pin calculation_version: 1.0.3.
POST /api/v1/calc/gcf
{ "inputs": { "values": [8, 12, 20] } }
Share URL: /calc/math/gcf?numsInput=8,12,20. Aliases: numbers, numsInput.
Stable error codes: MISSING_REQUIRED_INPUT, NEED_TWO_NUMBERS, INVALID_NUMBER, VALUE_ABOVE_MAX, UNDEFINED.
Input, exactness and data paths
Provide 2–32 integers, each with at most 48 decimal digits (sign excluded; leading zeros count). Arrays values/numbers accept safe JSON integer numbers or signed decimal strings. List strings values, numbers, and numsInput split on whitespace, commas or semicolons; empty separator runs are ignored. List text is limited to 4096 characters and each individual array string to 128 characters. Unknown fields are rejected. If multiple aliases are supplied, their normalized ordered integer lists must match; an explicit empty alias is an error. Scientific/hexadecimal/decimal-fraction text is rejected. Numeric JSON literals first follow binary64 parsing: unsafe integers are rejected; send large integers as strings. Nonzero raw JSON underflow is rejected before it becomes 0. Exactness refers to the accepted integer list, not to digits already rounded by a client's number representation.
MISSING_REQUIRED_INPUT means an absent/empty list; NEED_TWO_NUMBERS a single item; TOO_MANY_VALUES more than 32; INVALID_INPUT wrong list type; INVALID_NUMBER a bad or unsafe integer; VALUE_ABOVE_MAX more than48 digits; INPUT_TOO_LARGE oversized text; INPUT_ALIAS_CONFLICT inconsistent lists; UNKNOWN_INPUT an unknown field; UNDEFINED all zero. GCF(0,0) is deliberately undefined on this product, whereas Python math.gcd returns 0 by library convention. There are no physical units or floating-point approximation tolerance for the accepted exact integer result.
Factor-list cross-checks run on nonzero absolute inputs up to 10,000, prime checks up to 1,000,000. Zeros are excluded from those cross-checks; the prime worked view is omitted when zeros occur. Euclidean working is always provided. Leading zero-only accumulator steps are explicitly skipped; they do not assert a defined GCF(0,0). These same-implementation checks are not independent certification. Complete Copy JSON/CSV includes gcf_output (normalized values, exact result, method availability/results, and full work), raw active inputs, status and calculation version. Clear resets the current form; empty shared links remain empty. Old-version share links use the current engine with a notice, not a historical runtime.
Interactive arithmetic runs locally without an account. Shared links send inputs for server rendering; REST/MCP send inputs for execution. Shared history can store up to 20 entries in browser localStorage; Clear does not promise to erase history. Analytics can load under site configuration; retention/deletion, masking and processing region are not established here. The 32-value and 48-digit limits bound working/output size and are product limits, not mathematical limits.
Related tools
Other calculators in this family: Arithmetic Sequence Calculator, Factorial Calculator, Fibonacci Calculator, Geometric Sequence Calculator, LCM Calculator, Modular Inverse Calculator, Modulo Calculator, Permutation Combination Calculator . Explore all Number Theory & Discrete Math.
Frequently asked questions
Key distinctions behind the calculation.
What is the greatest common factor?
It is the largest positive integer that divides each of the given integers evenly (zero remainder). Also called GCD or HCF.
Are GCF, GCD, and HCF the same?
Yes. Greatest common factor, greatest common divisor, and highest common factor refer to the same value.
How do I find the GCF by factoring?
List the positive factors of each nonzero number and take the largest value that appears in every list.
How does prime factorization work?
Factor each nonzero number into primes. Multiply the primes that appear in every factorization, using the lowest shared exponent for each prime.
What is the Euclidean algorithm?
Repeatedly replace the larger number by the remainder when it is divided by the smaller, until the remainder is 0. The last nonzero remainder is the GCF. For more than two numbers the calculator folds that pairwise step.
What about GCF with 0?
GCF(k, 0) = |k| for nonzero k, because every k divides 0. A set that is entirely zeros is undefined. Mixed zeros such as 0, 0, 5 equal GCF(5) = 5.
Do you accept negative integers?
Yes. Negatives are treated by absolute value, so GCF(−8, 12, 20) = 4.
How large can the integers be?
Each integer may have at most 48 decimal digits. Arithmetic uses exact BigInt, so values larger than JavaScript’s MAX_SAFE_INTEGER (9,007,199,254,740,991) stay exact — for example GCF(9007199254740993, 3) = 3.
How is GCF used with fractions?
To simplify a/b, divide both parts by GCF(a,b). Example: 8/12, GCF=4 → 2/3.