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

All parameters set. Ready to execute!
Money Starter Kit

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.

No Spam
Privacy First
Instant Access
Client-Side Privacy
Instant Response
100% Free Forever

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

NumbersGCDLCMProductGCD x LCM
12, 18636216216
48, 361214417281728
100, 752530075007500
17, 131 (coprime)221221221
252, 1052112602646026460

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

  1. Enter Numbers: Input two or more positive integers separated by commas, spaces, or newlines.
  2. Execute Calculation: Click "Calculate GCD." The Euclidean algorithm runs iteratively across all inputs.
  3. Review Steps: Every division step is displayed with full algorithmic transparency.
  4. 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.

More Number Tools

Browse All

Min-Max Scaling Calculator

Kaprekar Number Checker

Digit Sum Calculator

Normalize Number to 0-1 Range

Significant Figures Calculator

Number Reversal Tool

Geometric Sequence Generator

Modular Arithmetic Calculator

Map Number Between Ranges

Integer Partition Generator

Pascal's Triangle Generator

Fibonacci Sequence Generator

Collatz Sequence Generator

Random Float Generator

Random Number Generator

Arithmetic Sequence Generator

Auto-Incrementing Number List

Prime Number List Generator

Number Format Localizer

Next Prime Finder

LCM Calculator

List of Divisors Generator

BCD Encoder

Happy Number Checker

Perfect Number Checker

Prime Number Checker

Prime Factorization Calculator

Number Digit Counter

Ordinal Number Formatter

Continued Fraction Converter

Number to IEEE 754 Formatter

BCD Decoder

Clamp Number to Range

Number Permutation Counter (nPr)

Factorial Calculator

Amicable Number Checker

Number Palindrome Checker

Fibonacci Number Checker

Armstrong Number Checker

Abundant Number Checker

Number Combination Counter (nCr)

Euler's Totient Calculator

Percentage to Fraction Converter

Percentage to Decimal Converter

Improper Fraction to Mixed Number

Mixed Number to Improper Fraction

Decimal to Fraction Converter

Fraction to Decimal Converter

Convert Number Between Bases

Roman Numerals to Number

Number to Roman Numerals

Engineering Notation Converter

Scientific Notation Converter

Number to Words Converter

Number Formatter