Example 1
- a = 48
- b = 18
6
What is GCD(48, 18)? 6 — 12 no longer divides 18.
Enter two integers. The calculator computes GCD — the greatest common divisor — with Euclid’s algorithm. GCD(48, 18) = 6; GCD(17, 13) = 1, because they are coprime. The form takes a pair only, not three numbers at once.
Enter two integers, for example 48 and 18.
GCD is computed for integers. Least common multiple lives on the LCM calculator. Reducing a ratio: ratio of two numbers.
GCD (greatest common divisor) is the largest positive integer that divides both entered numbers with no remainder. GCD(48, 18) = 6, because 48 = 6 × 8 and 18 = 6 × 3, while 12 no longer divides 18. GCD(17, 13) = 1: the numbers are coprime. The calculator uses the whole numbers you enter in fields nwd-a and nwd-b.
Mathematical model: Euclid’s algorithm (Elements, Book VII). Repeat (a, b) → (b, a mod b) on absolute values until the remainder is zero; the last nonzero divisor is the GCD. For 48 and 18: 48÷18 → 12, 18÷12 → 6, 12÷6 → 0, so the result is 6. When one number is zero, the result is the absolute value of the other. The pair 0 and 0 is rejected.
The fields are First number and Second number — integers only. Enter 48 and 18, then Calculate. A minus does not change GCD: GCD(−48, 18) = 6. A fraction 12.5 is rejected. The panel shows remainder steps, |a|, |b|, a preview a/d : b/d, and LCM = |a·b|/GCD when both are nonzero.
LCM also lives on its own page. Reducing ratio 48:18 by 6 gives 8:3 on the ratio-of-two-numbers page. Remainder (modulo) is a different question.
Worked examples: GCD(48, 18) = 6; GCD(17, 13) = 1; GCD(0, 25) = 25; GCD(100, 100) = 100; GCD(84, 36) = 12; GCD(144, 96) = 48; GCD(270, 192) = 6; GCD(35, 49) = 7. This is not a 0–100 scale — only the common divisor.
GCD(a, b) = largest d > 0 such that d | a and d | b (on |a|, |b|).
Euclid’s algorithm: (a, b) → (b, a mod b) until remainder = 0; the last nonzero divisor is the GCD. Fields: nwd-a, nwd-b.
Model: Euclid’s algorithm (Elements, Book VII).
The greatest common divisor of two integers a and b (written GCD(a, b), also HCF) is the largest positive integer d such that d | a and d | b. Equivalently, d is the largest positive common divisor of the absolute values |a| and |b|. When a = b = 0 the notion is not defined here — the calculator rejects that pair. When exactly one number is zero, GCD(0, b) = |b| for b ≠ 0.
This calculator implements Euclid’s algorithm: on absolute values it repeats (x, y) → (y, x mod y) until y = 0; then x is the GCD. Computation: repeatedly replace the pair (a, b) with (b, a mod b) until b = 0; the last non-zero a is the GCD. Mathematical model: Euclid’s algorithm / Euclidean algorithm. Descriptive sources: Euclid, Elements (Book VII); Wikipedia — Greatest common divisor; MathWorld — Greatest Common Divisor; Hardy & Wright, An Introduction to the Theory of Numbers.
In teaching practice it helps to separate the number-theoretic definition from computer-arithmetic limits: the calculator requires finite integers and shows the result of that computation, not a symbolic proof on paper. Bézout’s identity (integers x, y with ax + by = GCD) is true, but this form does not hunt Bézout coefficients — only d itself.
Euclid’s algorithm is among the oldest described computational procedures. In Euclid’s Elements (c. 3rd century BCE), especially Book VII on the arithmetic of integers, a geometric and arithmetic form of repeated subtraction / division with remainder leads to a common measure. Modern a mod b notation and the remainder loop are the same core: common divisors of a and b are also common to b and a mod b.
Coprimality (GCD = 1) runs through number theory, cryptography (RSA exponents coprime to φ(n)), and fraction reduction. LCM ties to GCD by LCM(a, b)·GCD(a, b) = |a·b| for nonzero a, b. In school, GCD appears when reducing fractions, building common denominators, and simplifying ratios.
Conceptually, GCD is not a single-division remainder (modulo), not LCM, and not the quotient a/b. Modulo supplies the remainder used in Euclid’s steps; LCM seeks a common multiple; a ratio divides both parts by the GCD. Here the only question is: what is the largest d dividing both numbers.
Domain of this calculator: a, b ∈ ℤ, not both zero. GCD(a, b) = GCD(|a|, |b|) = GCD(b, a). GCD(a, 0) = |a| when a ≠ 0. GCD(ka, kb) = |k|·GCD(a, b) for integer k. If d = GCD(a, b), then GCD(a/d, b/d) = 1.
Euclid invariant: the set of common divisors of a and b equals that of b and a mod b (when b ≠ 0). Hence correctness: each remainder preserves common divisors, and when the remainder vanishes the previous divisor is the greatest common one.
Complexity: the number of steps is O(log min(|a|, |b|)) in the typical case; worst-case behavior links to Fibonacci numbers (slow remainder decay). School examples (48, 18, 84, 36) need only three or four steps.
In teaching practice it helps to separate the mathematical identity from floating-point limits: above 2⁵³ not every integer is exactly representable in floating-point arithmetic. Typical school examples fit with room to spare.
Step 1. Enter two integers a and b. The parser accepts comma or period, but the value must come out integer. An empty field does not substitute zero for a missing entry.
Step 2. Reject the pair 0, 0. Take A = |a|, B = |b|.
Step 3. While B ≠ 0: R = A % B; A ← B; B ← R. Record each step in the panel as A = q·B + R.
Step 4. When B = 0, GCD = A. For 48 and 18: (48, 18) → (18, 12) → (12, 6) → (6, 0), so GCD = 6.
Step 5. Optionally: a/d and b/d give a reduced pair (ratio preview); LCM = |a·b|/d when a ≠ 0 and b ≠ 0.
Step 6. The chip figure shows a, b → remainder chain → GCD. That is the same path, not a separate model.
GCD(48, 18) = 6; GCD(17, 13) = 1; GCD(0, 25) = 25; GCD(100, 100) = 100; GCD(84, 36) = 12; GCD(144, 96) = 48; GCD(270, 192) = 6; GCD(35, 49) = 7; GCD(−48, 18) = 6.
Fraction 12.5 with 8: “not integer” error. 0 with 0: domain error. Field order does not change the GCD (commutativity), but it changes how steps are written when you start from the smaller number — the algorithm still reaches the same d.
When GCD = 1 the integers are coprime: they cannot be reduced by a common divisor larger than 1. When |a| = |b| ≠ 0, GCD = |a|.
The % operator and loop run on floating-point numbers. For |a|, |b| above 2⁵³ precision artifacts can appear — educational tool, not an arbitrary-precision system. Comma and period are equivalent.
The calculator does not solve ax + by = d (Bézout), does not factor primes, and does not compute GCD of many arguments at once — only a pair. Multi-argument LCM needs a separate iterative strategy.
Locale display (en-US) does not change the internal value: GCD(48, 18) is exactly 6.
Related: LCM; ratio of two numbers (reduce by GCD); modulo (remainder in Euclid’s steps); ordinary fractions / reduction; coprime integers. Bézout’s identity and the extended Euclidean algorithm sit one step further — outside this form.
Sources: Euclid, Elements, Book VII (arithmetic, common measure); Hardy & Wright, An Introduction to the Theory of Numbers; Knuth, The Art of Computer Programming (GCD algorithms); Wikipedia — Greatest common divisor; MathWorld — Greatest Common Divisor. Educational tool — not a substitute for a textbook or instructor check.
GCD = greatest common divisor. GCD(48, 18) = 6. The panel also shows Euclid’s steps.
6
What is GCD(48, 18)? 6 — 12 no longer divides 18.
1
What is GCD(17, 13)? 1 — the numbers are coprime.
25
What is GCD(0, 25)? 25, because GCD(0, b) = |b|.
100
What is GCD(100, 100)? 100 — two equal nonzero values.
12
What is GCD(84, 36)? 12.
48
What is GCD(144, 96)? 48.
6
What is GCD(270, 192)? 6 — Euclid’s remainder chain.
7
What is GCD(35, 49)? 7.
GCD is the greatest common divisor: the largest positive integer that divides both entered numbers with no remainder. For 48 and 18 it is 6, because 48 = 6×8 and 18 = 6×3, while 12 no longer divides 18.
Euclid’s algorithm on absolute values: repeat (a, b) → (b, a mod b) until the remainder is 0; the last nonzero divisor is the GCD. Computation: the calculator — the same steps as the textbook form.
GCD divides both numbers. LCM (least common multiple) is divisible by both. For nonzero a and b, LCM(a, b) = |a·b| / GCD(a, b). The panel shows that LCM as a helper; a separate LCM page computes it directly.
Divide and take remainders. For 48 and 18: 48÷18 → remainder 12; 18÷12 → 6; 12÷6 → 0. The last nonzero remainder is 6 = GCD.
The result is the absolute value of the other: GCD(0, 25) = 25. The pair 0 and 0 is rejected — GCD(0, 0) is not defined here.
Yes. GCD looks at size: GCD(−48, 18) = GCD(48, 18) = 6. Sign does not change the common divisor in this convention.
No. Integers only (⌊n⌋ === n). A fraction such as 12.5 does not produce a result — outside this tool’s domain.
Divide both parts by the GCD. Ratio 12:8 with GCD = 4 reduces to 3:2 on the ratio-of-two-numbers page. Here the calculator reports the GCD itself and a preview a/d : b/d.
No. The result depends only on the entered integers. The currency and unit settings in the page header do not affect this result.
Remainder (modulo) is on the modulo page. LCM is on the LCM calculator. Here the only question is: what is the greatest common divisor.
Divide the larger by the smaller and take the remainder, then repeat with the divisor and remainder until the remainder is 0. The last nonzero remainder is the GCD. For 48 and 18: remainders 12, then 6, then 0 — result 6.
GCD(48, 18) = 6. Both divide by 6 with no remainder, and 12 no longer divides 18. That is the first example on this page.
The numbers are coprime: they share no common divisor greater than 1. Example: GCD(17, 13) = 1. That is a valid result, not an error.
No. The form takes only two integers. For three numbers compute pairwise: GCD(GCD(a, b), c). Here the tool stays on a pair.
Divide numerator and denominator (or both ratio parts) by the GCD. For 24/36, GCD = 12 gives 2/3. The panel shows a/d : b/d; full ratio reduction lives on the ratio-of-two-numbers page.
The GCD definition, Euclid’s algorithm, and Book VII come from established sources.
Page Updated November 2, 2026.