Wiki

GCF & LCM: Greatest Common Factor and Least Common Multiple

How to find GCF using the Euclidean algorithm, LCM from GCF, and prime factorization methods. Formulas and worked examples.

Verified against Wolfram MathWorld - Greatest Common Divisor on 20 Feb 2025 Updated 20 February 2025 4 min read
Open calculator
Read in other languages (4)

Summary

The Greatest Common Factor (GCF) of two or more integers is the largest positive integer that divides each of them without a remainder. The Least Common Multiple (LCM) is the smallest positive integer that is a multiple of each of them. These two concepts are fundamental in simplifying fractions, finding common denominators, and solving problems in number theory.

How it works

There are two main approaches:

  1. Euclidean algorithm — the most efficient method for finding GCF. It repeatedly divides the larger number by the smaller and takes the remainder until the remainder is zero. The last non-zero remainder is the GCF.
  2. Prime factorization — factor each number into primes. The GCF is the product of all shared prime factors (taken at their lowest power). The LCM is the product of all prime factors (taken at their highest power).

Once you have the GCF, you can find the LCM using the relationship between them.

The formulas

LCM(a, b) = |a * b| / GCF(a, b)

Where

a, b= The two integers
GCF(a, b)= Greatest common factor of a and b
|a * b|= Absolute value of the product
Euclidean: GCF(a, b) = GCF(b, a mod b), until remainder = 0

Where

a mod b= The remainder when a is divided by b
GCF(a, 0)= Base case: GCF(a, 0) = a

Worked examples

GCF of 48 and 18 using the Euclidean algorithm

1

Divide 48 by 18

48 = 18 * 2 + 12

= remainder 12

2

Divide 18 by 12

18 = 12 * 1 + 6

= remainder 6

3

Divide 12 by 6

12 = 6 * 2 + 0

= remainder 0 -- stop

Result

GCF(48, 18) = 6

LCM of 48 and 18

1

Use GCF from above

GCF(48, 18) = 6

= 6

2

Apply the LCM formula

|48 * 18| / 6 = 864 / 6

= 144

Result

LCM(48, 18) = 144

Prime factorization method for GCF and LCM of 60 and 90

1

Factor 60

60 = 2^2 * 3 * 5

= 2^2 * 3 * 5

2

Factor 90

90 = 2 * 3^2 * 5

= 2 * 3^2 * 5

3

GCF: take minimum powers of shared primes

2^1 * 3^1 * 5^1

= 30

4

LCM: take maximum powers of all primes

2^2 * 3^2 * 5^1 = 4 * 9 * 5

= 180

Result

GCF(60, 90) = 30, LCM(60, 90) = 180

Practical uses

  • Simplifying fractions — divide numerator and denominator by their GCF to reduce a fraction to lowest terms (e.g., 48/18 becomes 8/3).
  • Adding fractions — the LCM of the denominators gives the least common denominator, making addition straightforward.
  • Scheduling — if event A repeats every 12 days and event B every 18 days, they next coincide in LCM(12, 18) = 36 days.
  • Tiling and measurement — the GCF determines the largest square tile that evenly covers a rectangular floor.

Assumptions & limitations

  • Positive integers only — GCF and LCM are defined for positive integers. The calculator takes absolute values of any negative inputs.
  • GCF of zero — GCF(a, 0) = a by convention, since every integer divides 0. LCM(a, 0) = 0 since 0 is a multiple of everything.
  • More than two numbers — the Euclidean algorithm extends naturally: GCF(a, b, c) = GCF(GCF(a, b), c), and similarly for LCM.

Sources

Academic
gcf lcm gcd euclidean-algorithm prime-factorization math