GCD / HCF Calculator
Compute GCD (HCF) and LCM of 2+ integers using the Euclidean algorithm with step-by-step division display and coprimality check.
Input
Result

Get Free Money Making Tips
Join 2,000+ smart readers getting side-hustle ideas, passive income strategies, and proven finance tips delivered straight to your inbox.
GCD / HCF Calculator: Compute Greatest Common Divisor with Euclidean Algorithm Step-by-Step
The GCD / HCF Calculator computes the Greatest Common Divisor (also called Highest Common Factor) of two or more integers using the Euclidean algorithm, displaying every division step. It simultaneously calculates the Least Common Multiple (LCM) and determines coprimality. In "Number Theory," "Fraction Simplification," and "Cryptographic Key Generation," the GCD is one of the most fundamental arithmetic operations. The Euclidean algorithm, first documented in Euclid's Elements (Book VII, circa 300 BCE), is the oldest known non-trivial algorithm still in active computational use. Modern implementations of RSA, Diffie-Hellman, and ECC all depend on efficient GCD computation.
What is GCD and how does the Euclidean Algorithm work?
The Greatest Common Divisor (GCD) of two or more integers is the largest positive integer that divides each of them without a remainder. The Euclidean algorithm computes GCD(a, b) by repeatedly replacing the larger number with the remainder of dividing it by the smaller: GCD(a, b) = GCD(b, a mod b), until the remainder is 0. For GCD(252, 105): 252 = 2 x 105 + 42; 105 = 2 x 42 + 21; 42 = 2 x 21 + 0. GCD = 21. The algorithm runs in O(log(min(a,b))) time.
GCD/LCM Relationship Table
| Numbers | GCD | LCM | Product | GCD x LCM |
|---|---|---|---|---|
| 12, 18 | 6 | 36 | 216 | 216 |
| 48, 36 | 12 | 144 | 1728 | 1728 |
| 100, 75 | 25 | 300 | 7500 | 7500 |
| 17, 13 | 1 (coprime) | 221 | 221 | 221 |
| 252, 105 | 21 | 1260 | 26460 | 26460 |
6 Mathematical and Engineering Applications
- Fraction Simplification: To reduce 48/36 to lowest terms, divide both by GCD(48, 36) = 12, yielding 4/3.
- RSA Key Generation: RSA requires GCD(e, phi(n)) = 1. The extended Euclidean algorithm computes the modular inverse d = e^-1 mod phi(n).
- Clock Arithmetic: LCM determines when two periodic events coincide. Clock A chimes every 12 min, clock B every 18 min: they coincide every LCM(12,18) = 36 min.
- Gear Ratio Calculation: A 48:36 gear ratio simplifies to 4:3 via GCD(48,36) = 12.
- Musical Intervals: The perfect fifth frequency ratio 3:2 is derived by simplifying actual frequency ratios using GCD.
- Tiling Problems: The largest square tile for a 252cm x 105cm floor is GCD(252,105) = 21cm.
How to Use the GCD / HCF Calculator
- Enter Numbers: Input two or more positive integers separated by commas, spaces, or newlines.
- Execute Calculation: Click "Calculate GCD." The Euclidean algorithm runs iteratively across all inputs.
- Review Steps: Every division step is displayed with full algorithmic transparency.
- Verify Properties: GCD x LCM = product of inputs (for two numbers) and coprimality status are confirmed.
Extended Euclidean Algorithm and Bezout's Identity
The Extended Euclidean Algorithm computes coefficients x and y such that ax + by = GCD(a, b). This is Bezout's Identity, proven by Etienne Bezout (1779). For GCD(252, 105) = 21: 252 x (-2) + 105 x (5) = 21. The extended algorithm is essential for modular multiplicative inverses required in RSA decryption and Chinese Remainder Theorem applications.
Frequently Asked Questions
What is the difference between GCD and HCF?
GCD and HCF are identical concepts with different names. GCD is standard in American mathematics; HCF is used in British and Commonwealth education.
Can I compute GCD for more than 2 numbers?
The calculator supports any number of inputs (2 or more). GCD(a, b, c) = GCD(GCD(a, b), c).
What if one input is 0?
GCD(a, 0) = a for any non-zero a. Zero is divisible by every integer.
How is LCM calculated from GCD?
LCM(a, b) = |a x b| / GCD(a, b). This is the most efficient LCM computation method.
What does coprime mean?
Two numbers are coprime if their GCD is 1. They share no common factor other than 1. Coprimality is critical in modular arithmetic and cryptography.