How Greatest Common Divisor Calculator Works?
The Greatest Common Divisor Calculator works in 5 steps: it reads 2 integers, takes absolute values, runs the Euclidean algorithm, stops at a zero remainder, and returns the greatest common divisor (GCD). The output line reads GCF = n, as GCD and GCF name the same value.
Enter the 2 integers
Type the integers in the 2 numerator fields, for example 252 and 105. Keep both denominators non-zero.
Drop the signs
The calculator converts each input to its absolute value, so GCD(−252, 105) equals GCD(252, 105).
Divide and keep the remainder
The first division is 252 = 2 × 105 + 42. The pair (252, 105) becomes (105, 42).
Repeat until the remainder is 0
105 = 2 × 42 + 21, then 42 = 2 × 21 + 0. The algorithm stops after 3 divisions.
Return the GCD
The last non-zero remainder is 21, so the result panel prints
GCF = 21. 252 ÷ 21 = 12 and 105 ÷ 21 = 5.
Greatest Common Divisor Calculator Formula
The greatest common divisor formula is gcd(a, b) = gcd(b, a mod b), with gcd(a, 0) = |a|. Euclid described this division method around 300 BC.
Euclidean algorithm
Replace the pair with the smaller number and the remainder. The remainder shrinks at every step, so the loop always ends.
Base case
Every integer divides 0, so the GCD of a number and 0 is the absolute value of that number.
Bézout identity
Integers x and y exist for every pair. For 252 and 105, 21 = 252 × (−2) + 105 × 5.
Binary GCD rule
Computers halve even inputs with bit shifts. gcd(270, 192) = 2 × gcd(135, 96) = 2 × 3 = 6.
Worked example: gcd(1071, 462)
- Divide: 1071 = 2 × 462 + 147.
- Divide: 462 = 3 × 147 + 21.
- Divide: 147 = 7 × 21 + 0.
- The remainder is 0, so the GCD is the last divisor: 21.
- Check: 1071 = 21 × 51 and 462 = 21 × 22, and gcd(51, 22) = 1.
Greatest Common Divisor Calculator Conversion Table
The greatest common divisor conversion table lists 12 integer pairs with the first Euclidean division, the number of divisions, the GCD, and the coprime status.
| Integer Pair | First Division Step | Division Steps | GCD | Coprime? |
|---|---|---|---|---|
| 270, 192 | 270 = 1 × 192 + 78 | 4 | 6 | No |
| 662, 414 | 662 = 1 × 414 + 248 | 5 | 2 | No |
| 1001, 143 | 1001 = 7 × 143 + 0 | 1 | 143 | No |
| 210, 45 | 210 = 4 × 45 + 30 | 3 | 15 | No |
| 391, 299 | 391 = 1 × 299 + 92 | 3 | 23 | No |
| 546, 390 | 546 = 1 × 390 + 156 | 3 | 78 | No |
| 987, 610 | 987 = 1 × 610 + 377 | 14 | 1 | Yes |
| 1980, 1260 | 1980 = 1 × 1260 + 720 | 4 | 180 | No |
| 437, 323 | 437 = 1 × 323 + 114 | 4 | 19 | No |
| 144, 89 | 144 = 1 × 89 + 55 | 10 | 1 | Yes |
| 2024, 1518 | 2024 = 1 × 1518 + 506 | 2 | 506 | No |
| 858, 330 | 858 = 2 × 330 + 198 | 4 | 66 | No |
What is Greatest Common Divisor Calculator?
A Greatest Common Divisor Calculator is a tool that returns the largest positive integer that divides 2 integers exactly, computed with the Euclidean algorithm. The greatest common divisor (GCD) of 391 and 299 is 23.
The term GCD comes from number theory and computer science. Programming languages ship a built-in GCD function, for example math.gcd in Python and std::gcd in C++. Both functions use the same remainder loop as the calculator.
The Euclidean algorithm is fast for large inputs. The worst case happens with consecutive Fibonacci numbers: gcd(987, 610) takes 14 divisions and ends at 1. A pair whose smaller number has 6 digits needs at most 30 divisions.
What are the uses of Greatest Common Divisor Calculator?
The Greatest Common Divisor Calculator has 6 main uses, including fraction reduction, cryptography practice, and code testing.
Fraction reduction
Dividing
546/390by the GCD 78 returns 7/5.Cryptography practice
Students confirm that an RSA public exponent and φ(n) are coprime, for example gcd(17, 3120) = 1.
Code testing
Programmers compare the output of a custom GCD function against known pairs such as gcd(2024, 1518) = 506.
Linear congruences
The congruence
6x ≡ 4 (mod 10)has solutions: gcd(6, 10) = 2 divides 4. A congruencea·x ≡ b (mod m)has no solution, if gcd(a, m) does not divide b.Screen aspect ratios
A 1920 × 1080 display has gcd(1920, 1080) = 120, which gives the aspect ratio 16:9.
Number theory proofs
Students test Bézout coefficients and coprime pairs such as 144 and 89 before writing formal proofs.