HomeCalculatorsMathNumber Theory & Discrete MathGCF Calculator
Math calculator

GCF Calculator

Find the GCF, GCD, or HCF of two or more integers. Exact BigInt Euclidean fold with factor and prime cross-checks. Free, no sign-up.

Instant result
Result

Enter values to calculate.

Inputs
Mode
Formula
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 integers; ignore zeros unless all zero
  • 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.2 · CVP VERIFIED · CVP protocol 1.0.0-proposed · Core assurance· View Manifest · CVP overview · Specification
Versions
Calculation 1.0.2 · CVP protocol 1.0.0-proposed · Evidence 2026-09-16.sources-no-wolfram
Verification revision
2026-09-16.sources-no-wolfram · 3/3 property · digest 2f7e2bf9bb70
Legacy regression
20/20 tests · Production surface contract 3/3
Trust layers
Verification VERIFIED · Production CURRENT · overall VERIFIED
Reference
O1 model · O2 expected_values · O2 numerical_behavior
Interfaces
PASS · UI (SSR) / REST / MCP — ui-ssr is query-result HTML, not a live browser session.
Supplemental domain review
Not performed
Named expert review
Not performed
CVP suite
4/4 golden · 7/7 CVP boundary · 5/5 invalid · 3/3 property · 1/1 metamorphic · 1/1 cross-interface · 5/5 cross-calculator · 3/3 CVP contract · Manifest
Sources
Sources
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 · 4/4 oracle-backed golden · 5/5 invalid · Artifact integrity PASS
This calculator CURRENT · Public schema 1.0.2 matches · Semantic contract ✓ · Production attested · Public/cache ✓ · Origin ✓
Semantic contract
PASS
Full verification

Manifest identity, reference classes, interfaces, suite, and production records.

Formulas

Core equations used by this calculator.

PairwiseGCF(a,b,c,…) = GCF(GCF(a,b),c,…)
EuclideanGCF(a,b) = GCF(b, a mod b) until remainder 0
With zeroGCF(k, 0) = |k| (k ≠ 0); all zeros undefined
Fractionsa/b = (a÷g)/(b÷g) where g = GCF(a,b)
iGCF, GCD, and HCF name the same idea. Results are positive. Absolute values are used for negative inputs. Zeros are ignored unless every input is 0.

How to use

1

Enter two or more integers

Separate with commas or spaces (e.g. 8, 12, 20). Negatives use absolute value.

2

Calculate

Read the GCF plus factor / prime / Euclidean working when the values are small enough to list.

3

Optional: simplify a fraction

Divide numerator and denominator by their GCF.

Example calculations

Common configurations with formula and result.

ϟ

Three numbers

8, 12, 20

common factors → 4
4
ϟ

Prime method

18 and 27

3×3
9
ϟ

Euclidean

48 and 18

48=2·18+12; …
6
ϟ

With zero

GCF(5, 0)

GCF(k,0)=|k|
5
ϟ

Zeros then a nonzero

0, 0, 5

ignore zeros
5

Quick checks

Common values at a glance.

NumbersGCF
8, 12, 204
18, 279
20, 50, 12010
16, 88, 1048
32, 25632
5, 05
0, 0, 55
0, 0undefined
i GCF of a set that is all zeros is undefined. Zeros among nonzero integers do not change the GCF. For large sets, the Euclidean algorithm is usually faster than listing every factor by hand.

GCF calculator specification

Version 1.0.2 · Engine tested

Calculation status

Review policy · Evidence

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 3/3 · 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 form
    Supports: 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 domain
    Supports: Negatives by |n|; ignore zeros unless the whole set is 0; exact BigInt with a product digit cap
Calculation version
1.0.2

Background

Interpretation and common distinctions.

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.2.

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.

}

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.