GCD Calculator
Calculate the Greatest Common Divisor (GCD) of two or more numbers using the Euclidean algorithm.
Enter Numbers
You can enter 2 or more numbers
Quick Examples:
GCD (Greatest Common Divisor), also known as GCF (Greatest Common Factor) or HCF (Highest Common Factor), is the largest positive integer that divides all given numbers without a remainder.
GCD of 24, 36
12
Prime Factorizations:
Euclidean Algorithm Steps:
Divisibility:
24 ÷ 12 = 2, 36 ÷ 12 = 3
The Euclidean Algorithm
The Euclidean algorithm is an efficient method for computing the GCD of two numbers. It works by repeatedly dividing the larger number by the smaller one and taking the remainder until the remainder is zero. The last non-zero remainder is the GCD.
GCD(a, b) = GCD(b, a mod b), where a mod b is the remainder when a is divided by b
Applications of GCD
Simplifying Fractions
Divide numerator and denominator by their GCD
Music Theory
Finding beat patterns and time signatures
Cryptography
RSA encryption uses GCD calculations
Gear Ratios
Calculating optimal gear combinations
What is the Greatest Common Divisor (GCD)?
The Greatest Common Divisor (GCD), also known as the Greatest Common Factor (GCF) or Highest Common Factor (HCF), is the largest positive integer that divides two or more numbers without leaving a remainder. Understanding GCD is fundamental to number theory and has practical applications in simplifying fractions, solving problems, and working with ratios.
Key Terminology:
- GCD (Greatest Common Divisor) - Most common term in mathematics
- GCF (Greatest Common Factor) - Common in elementary education
- HCF (Highest Common Factor) - Common in British English
Basic Properties of GCD:
- GCD(a, b) = GCD(b, a) - Commutative property
- GCD(a, 0) = |a| for any integer a
- GCD(a, 1) = 1 for any integer a
- GCD(a, a) = |a| for any integer a
- If GCD(a, b) = 1, then a and b are coprime (relatively prime)
Simple Examples:
- GCD(12, 18) = 6 (6 is the largest number dividing both)
- GCD(15, 25) = 5
- GCD(17, 23) = 1 (both are prime, so they're coprime)
- GCD(48, 36, 24) = 12
The Euclidean Algorithm
The Euclidean Algorithm is the most efficient method for finding the GCD, dating back over 2,300 years to the ancient Greek mathematician Euclid. It's based on the principle that the GCD of two numbers also divides their difference.
How It Works:
- Divide the larger number by the smaller number
- Take the remainder from step 1
- Replace the larger number with the smaller, and smaller with remainder
- Repeat until the remainder is 0
- The last non-zero remainder is the GCD
Euclidean Algorithm
Where:
- a, b= The two numbers to find GCD of (a ≥ b)
- mod= Modulo operation (remainder after division)
- GCD= Greatest Common Divisor result
Methods for Finding GCD
There are several approaches to find the GCD, each with its own advantages:
| Method | Process | Best For | Example |
|---|---|---|---|
| Euclidean Algorithm | Repeated division with remainders | Large numbers, efficiency | GCD(252, 105) → 21 |
| Prime Factorization | Find common prime factors | Understanding, small numbers | 36 = 2²×3², 48 = 2⁴×3 → GCD = 2²×3 = 12 |
| Listing Divisors | List all divisors, find largest common | Small numbers, teaching | 12: {1,2,3,4,6,12}, 18: {1,2,3,6,9,18} → GCD = 6 |
| Subtraction Method | Repeatedly subtract smaller from larger | Manual calculation, understanding | GCD(48,18): 48-18=30, 30-18=12, 18-12=6... |
Prime Factorization Method:
- Find the prime factorization of each number
- Identify common prime factors
- Take the lowest power of each common prime
- Multiply these together to get the GCD
GCD and LCM Relationship
The GCD and LCM (Least Common Multiple) have a fundamental mathematical relationship:
GCD-LCM Relationship
Where:
- GCD= Greatest Common Divisor
- LCM= Least Common Multiple
- a, b= The two numbers
How to Use This GCD Calculator
Our GCD calculator finds the greatest common divisor quickly and shows the steps:
- Enter Numbers: Input two or more integers (positive or negative)
- Click Calculate: The calculator finds the GCD
- View Results:
- GCD value
- Step-by-step Euclidean algorithm
- Prime factorizations
- Related LCM value
Features:
- Calculate GCD of 2, 3, or more numbers
- Works with negative numbers (returns positive GCD)
- Shows detailed solution steps
- Displays prime factorization
- Automatically calculates related LCM
Tips:
- For negative numbers, GCD uses absolute values
- GCD(0, n) = n for any non-zero n
- If result is 1, the numbers are coprime
Real-World Applications of GCD
The GCD has many practical applications:
Simplifying Fractions:
- To reduce a fraction, divide both numerator and denominator by their GCD
- Example: 24/36 → GCD(24,36) = 12 → 24÷12 / 36÷12 = 2/3
- A fraction is fully reduced when GCD of numerator and denominator is 1
Solving Problems:
- Tiling: Finding the largest square tile for a rectangular floor
- Distribution: Dividing items equally into groups
- Music: Finding rhythmic patterns and time signatures
- Computer Science: RSA encryption, hash functions
Cryptography:
- RSA encryption uses GCD to find coprime numbers
- Extended Euclidean algorithm finds modular inverses
- Essential for secure key generation
Engineering:
- Gear ratio calculations
- Signal processing
- Computer graphics (pixel aspect ratios)
Finding GCD of Multiple Numbers
To find the GCD of more than two numbers, apply the GCD function iteratively:
Method:
- GCD(a, b, c) = GCD(GCD(a, b), c)
- GCD(a, b, c, d) = GCD(GCD(GCD(a, b), c), d)
- Continue this pattern for any number of values
Example: GCD(24, 36, 48)
- First find GCD(24, 36) = 12
- Then find GCD(12, 48) = 12
- Therefore, GCD(24, 36, 48) = 12
Prime Factorization Method for Multiple Numbers:
- 24 = 2³ × 3
- 36 = 2² × 3²
- 48 = 2⁴ × 3
- GCD = 2² × 3 = 12 (lowest power of each common prime)
Worked Examples
Euclidean Algorithm Example
Problem:
Find GCD(252, 105) using the Euclidean Algorithm
Solution Steps:
- 1Start with a = 252, b = 105
- 2252 = 105 × 2 + 42 (remainder is 42)
- 3105 = 42 × 2 + 21 (remainder is 21)
- 442 = 21 × 2 + 0 (remainder is 0)
- 5The last non-zero remainder is 21
- 6Verify: 252 ÷ 21 = 12 ✓, 105 ÷ 21 = 5 ✓
Result:
GCD(252, 105) = 21
Prime Factorization Method
Problem:
Find GCD(180, 252) using prime factorization
Solution Steps:
- 1Factor 180: 180 = 2² × 3² × 5
- 2Factor 252: 252 = 2² × 3² × 7
- 3Identify common primes: 2 and 3
- 4Take lowest powers: 2² and 3²
- 5Multiply: 2² × 3² = 4 × 9 = 36
- 6Verify: 180 ÷ 36 = 5 ✓, 252 ÷ 36 = 7 ✓
Result:
GCD(180, 252) = 36
Simplifying a Fraction
Problem:
Simplify the fraction 84/126
Solution Steps:
- 1Find GCD(84, 126) using Euclidean algorithm
- 2126 = 84 × 1 + 42
- 384 = 42 × 2 + 0
- 4GCD(84, 126) = 42
- 5Divide both by GCD: 84÷42 / 126÷42
- 6Result: 2/3
Result:
84/126 = 2/3 (simplified)
Tips & Best Practices
- ✓Use the Euclidean Algorithm for large numbers - it's much faster than listing divisors
- ✓GCD helps simplify fractions: divide numerator and denominator by their GCD
- ✓For multiple numbers: GCD(a, b, c) = GCD(GCD(a, b), c)
- ✓If GCD = 1, the numbers are coprime (no common factors)
- ✓Remember: GCD(a, b) × LCM(a, b) = a × b - useful for finding LCM quickly
- ✓GCD of any number and 0 is the number itself: GCD(n, 0) = n
- ✓Prime numbers are coprime with all numbers they don't divide
Frequently Asked Questions
Sources & References
Last updated: 2026-01-22