Mathematics

How to Find the Greatest Common Factor of Two Numbers

The greatest common factor (GCF) of two numbers is found efficiently with the Euclidean algorithm — repeatedly replacing the larger number with the remainder of dividing it by the smaller, until the remainder reaches zero.

The Euclidean algorithm: repeated remainders

For 12 and 18: 18 ÷ 12 leaves a remainder of 6, so replace the pair with 12 and 6. Then 12 ÷ 6 leaves a remainder of 0 — once the remainder hits zero, the other number at that step, 6, is the GCF.

A second example

For 8 and 12: 12 ÷ 8 leaves a remainder of 4, giving the pair 8 and 4. Then 8 ÷ 4 leaves a remainder of 0, so the GCF is 4.

When one number divides the other evenly

For 17 and 34: 34 ÷ 17 leaves a remainder of 0 immediately, since 34 is exactly double 17 — so the GCF is 17 itself, the smaller of the two numbers.

Why this method beats listing every factor

Listing all the factors of both numbers and comparing them works for small numbers, but gets slow fast for large ones. The Euclidean algorithm reaches the answer in only a handful of division steps regardless of how large the two numbers are, which is why it's the standard method used in practice — including inside the fraction simplifier's own calculation, as the companion article on GCF and LCM explores.