GCD and LCM Calculator

Find the Greatest Common Divisor (GCD / HCF) and Least Common Multiple (LCM) of two positive whole numbers. For example, for 18 and 24, the GCD is 6 and the LCM is 72. Enter your numbers below for dynamic real-time calculations.

The formulas this calculator uses

The calculator employs the Euclidean Algorithm to compute the GCD, and then uses the fundamental relationship between GCD and LCM to derive the LCM:

GCD & LCM Mathematical Formulas

$\text{Euclidean Algorithm for GCD}(a, b): b_n = a \pmod b \quad \text{until } b = 0$
$$\text{LCM}(a, b) = \frac{|a \times b|}{\text{GCD}(a, b)}$$

Example Calculation (18 & 24):
• $24 \pmod{18} = 6 \implies 18 \pmod 6 = 0 \implies \mathbf{\text{GCD} = 6}$
• $\text{LCM} = \frac{18 \times 24}{6} = \frac{432}{6} = \mathbf{72}$

GCD and LCM reference table

A quick reference list of common integer pairs and their calculated GCD and LCM values:

Number Pair $(A, B)$ GCD (HCF) LCM Product Verification ($A \times B$)
12 and 18 6 36 $6 \times 36 = 216$
15 and 25 5 75 $5 \times 75 = 375$
24 and 36 12 72 $12 \times 72 = 864$
17 and 31 (Coprime) 1 527 $1 \times 527 = 527$

Practical applications of GCD and LCM

Understanding these fundamental number theory principles is essential in arithmetic and real-world problem solving:

  • Simplifying Fractions (GCD): To reduce a fraction like $\frac{18}{24}$ to its lowest terms, divide both numerator and denominator by their $\text{GCD} (6)$, yielding $\frac{3}{4}$.
  • Adding & Subtracting Fractions (LCM): Finding a Least Common Denominator (LCD) when adding fractions like $\frac{1}{18} + \frac{1}{24}$ requires finding the $\text{LCM}(18, 24) = 72$.
  • Scheduling Cycles (LCM): If event A happens every 18 minutes and event B every 24 minutes, both events happen simultaneously every $\text{LCM}(18, 24) = 72$ minutes.

How to use this calculator

  1. Enter the first integer into the Number A box.
  2. Enter the second integer into the Number B box.
  3. The computed GCD and LCM update immediately in real time.

Frequently asked questions

What is the GCD of two numbers?

The greatest common divisor (GCD) is the largest number that divides evenly into both numbers with no remainder.

What is the LCM of two numbers?

The least common multiple (LCM) is the smallest number that both numbers divide into evenly.

How does the Euclidean algorithm find the GCD?

It repeatedly replaces the larger number with the remainder of dividing it by the smaller number, continuing until the remainder reaches zero — the last non-zero remainder is the GCD.

Where are GCD and LCM used in everyday math?

GCD is used to simplify fractions to their lowest terms; LCM is used to find a common denominator when adding or comparing fractions.

Related math tools