GCD Calculator
Free GCD calculator: find the Greatest Common Divisor of two or more integers using the Euclidean algorithm. Also calcul
Calculator
Your Results
Enter your values and click Calculate to see results
How the GCD Calculator Works
The GCD calculator (1,600 monthly searches) finds the Greatest Common Divisor — also called Greatest Common Factor (GCF). The related "greatest common factor calculator" and "gcf calculator" together add 24,200 monthly searches, and "LCM calculator" adds another 8,100. This is a core discrete math and number theory tool used from middle school arithmetic through college-level computer science.
The calculator uses the Euclidean algorithm: GCD(a, b) = GCD(b, a mod b), recursively until the remainder is 0. Example: GCD(48, 18). Step 1: GCD(48, 18) = GCD(18, 48 mod 18) = GCD(18, 12). Step 2: GCD(18, 12) = GCD(12, 6). Step 3: GCD(12, 6) = GCD(6, 0) = 6. GCD(48, 18) = 6. Then LCM(48, 18) = (48 × 18) / 6 = 144.
Applications of GCD
- Fraction simplification: 48/18 = (48/6)/(18/6) = 8/3 (dividing both by GCD)
- Cryptography: RSA encryption requires numbers with GCD = 1 (coprime)
- Scheduling: LCM determines when two repeating events coincide next
- Gear design: GCD of gear teeth counts determines the hunting ratio
- Music theory: GCD of frequency ratios relates to harmonic intervals
Greatest Common Factor Calculator: Real Applications
The greatest common factor calculator (12,100 monthly searches) is used in several practical contexts beyond pure math:
- Simplifying fractions: To reduce 48/72, find GCF(48,72) = 24. Divide: 48/24 = 2, 72/24 = 3. Simplified: 2/3.
- Factoring expressions: To factor 12x2 + 18x, GCF = 6x. Factored: 6x(2x + 3).
- Finding common denominators: LCD(a,b) = a×b ÷ GCD(a,b). To add 5/12 + 7/18: GCD(12,18)=6, LCD=12×18/6=36. Convert: 15/36 + 14/36 = 29/36.
- Scheduling problems: Events occurring every 12 days and every 8 days next meet when? LCM(12,8) = 12×8/GCD(12,8) = 96/4 = 24 days.
- Music: Finding the rhythmic relationship between time signatures and polyrhythms.
LCM Calculator: Least Common Multiple
The LCM calculator (8,100 monthly searches) computes the smallest positive integer divisible by all input numbers. The GCD-LCM relationship: LCM(a,b) = (a × b) / GCD(a,b). This is always faster than prime factorization for two numbers. For three or more numbers: compute pairwise LCMs sequentially. LCM(12, 18, 24): LCM(12,18) = 36; LCM(36,24) = GCD(36,24)=12, so LCM = 36×24/12 = 72.
GCF Calculator: Finding GCF by Prime Factorization vs. Euclidean Algorithm
The GCF calculator can use two main methods. For small numbers, prime factorization is intuitive:
Prime factorization method: Factor each number completely, then take the product of the lowest powers of all common prime factors. GCF(180, 252): 180 = 22 × 32 × 5; 252 = 22 × 32 × 7. Common primes: 22 and 32. GCF = 22 × 32 = 4 × 9 = 36. Check: 180/36 = 5; 252/36 = 7 ✓.
Euclidean algorithm (faster for large numbers): GCF(1001, 819). Step 1: GCF(1001, 819) = GCF(819, 182). Step 2: GCF(819, 182) = GCF(182, 91). Step 3: GCF(182, 91) = GCF(91, 0) = 91. Much faster than factoring large numbers.
GCF for 3+ numbers: Compute pairwise. GCF(12, 18, 24): GCF(12,18) = 6; GCF(6,24) = 6. Final answer: 6.
GCD in Computer Science and Cryptography
The GCD is foundational to RSA encryption — the most widely used public-key cryptography system. RSA key generation requires finding two large coprime numbers (GCD = 1) and computing modular inverses using the Extended Euclidean Algorithm. Every HTTPS connection your browser makes uses this mathematics. In programming, the GCD appears in: fraction simplification, hash table sizing (prime-based), scheduling algorithms (finding LCM for task periods), and digital signal processing (finding common sample rates). Python's built-in math.gcd() and Java's BigInteger.gcd() implement the binary GCD algorithm for efficiency.
Frequently Asked Questions
What does it mean for two numbers to be coprime?
Two numbers are coprime (or "relatively prime") when their GCD = 1 — they share no common factor other than 1. Examples: 9 and 16 are coprime (GCD=1) despite neither being prime. 15 and 21 are not coprime (GCD=3). Coprimality is crucial in cryptography, number theory, and the Chinese Remainder Theorem. Consecutive integers are always coprime.
What is the GCD of 0 and any number?
By convention, GCD(a, 0) = a for any non-zero integer a. This is because every integer divides 0 (0 is divisible by everything), so the greatest divisor of a that also divides 0 is simply a itself. This edge case is handled correctly by the Euclidean algorithm: GCD(a, 0) = a since a mod 0 is undefined but by convention the algorithm terminates with a.