HCF Using Prime Factors

Introduction

Welcome back to Finding the Highest Common Factor! You are now on Lesson 3 of 4 in this course, which means you have already built a solid foundation. In the first two lessons, we identified common factors by listing and comparing factor lists, then selected the greatest one to find the HCF. That approach is reliable, but it can get slow when numbers grow larger.

In this lesson, we will learn a more efficient route: finding the HCF directly from the prime factorizations of the numbers involved. If you completed the earlier course on breaking numbers into primes, those skills are about to pay off in a big way.

From Factor Lists to Prime Factors

Listing every factor of a number works well for small values like 1212 or 1818. But imagine finding all the factors of 252252 or 360360 — the lists get long, and mistakes become easy to make.

Prime factorization gives us a shortcut because it breaks each number down to its basic building blocks. As you may recall from a previous course, every whole number greater than 11 has a unique prime factorization. Comparing those building blocks tells us exactly what two numbers have in common, without writing out every single factor. The core idea is simple: if a prime appears in both factorizations, it contributes to the HCF; if it appears in only one, it does not.

The Method: Shared Primes at Their Lowest Powers

Here is the step-by-step process for finding the HCF using prime factorization:

  1. Find the prime factorization of each number.
  2. Identify the primes that appear in every factorization (the shared primes).
  3. For each shared prime, take the lowest power that appears across the factorizations.
  4. Multiply these together to get the HCF.

If no prime is shared at all, the HCF is simply 11. As we saw in the previous lesson, that just means the numbers are coprime.

Flowchart showing the four-step process for finding HCF using prime factorization

Worked Example: HCF of 36 and 48

Let's see the method in action. First, we write the prime factorizations:

36=22×3236 = 2^2 \times 3^2 48=24×348 = 2^4 \times 3 Factor trees for 36 and 48 with shared prime factors highlighted

Now we compare prime by prime:

PrimePower in 3636Power in 4848Lowest power
22224422
33221111

Both factorizations contain 22 and 33, so both primes are shared. We take 22 at its lowest power (222^2) and 33 at its lowest power (313^1), then multiply:

HCF(36,48)=22×3=4×3=12\text{HCF}(36, 48) = 2^2 \times 3 = 4 \times 3 = 12

You can verify this with factor lists if you like: the factors common to 3636 and 4848 are 1,2,3,4,6,121, 2, 3, 4, 6, 12, and the greatest is indeed 1212.

Why Only Shared Primes Count

You might wonder why we ignore a prime that appears in only one factorization. The reason comes straight from the definition of "factor." For a number to divide both values evenly, every prime in that number must be present in both factorizations. A prime that is missing from one side simply cannot be part of any common factor.

Let's explore this with 6060 and 9090:

60=22×3×560 = 2^2 \times 3 \times 5 90=2×32×590 = 2 \times 3^2 \times 5

Here, the primes 22, 33, and 55 all appear in both factorizations, so each one contributes. Taking the lowest powers:

PrimePower in 6060Power in 9090Lowest power
22221111
33112211
55111111
HCF(60,90)=2×3×5=30\text{HCF}(60, 90) = 2 \times 3 \times 5 = 30

Why the Lowest Power?

It is also worth understanding why we pick the lowest power of each shared prime, not the highest. Look at the prime 22 in the example above: it appears as 222^2 in 6060 and as 212^1 in 9090. If we tried to include 222^2 in the HCF, the result would contain a factor of 44. But 9090 is not divisible by 44, so a number containing 222^2 could not divide 9090 evenly.

By choosing the lower power, we guarantee the HCF divides both numbers without a remainder. The lowest power is the most that both numbers can "afford" to share.

Extending to Three Numbers

The method works the same way with three or more numbers. A prime must appear in all factorizations to be included, and we still take the lowest power across the entire set. Let's find the HCF of 2424, 3636, and 6060:

24=23×324 = 2^3 \times 3 36=22×3236 = 2^2 \times 3^2 60=22×3×560 = 2^2 \times 3 \times 5 Venn diagram showing prime factors of 24, 36, and 60 with shared factors in the central region
PrimePower in 2424Power in 3636Power in 6060Shared?Lowest power
22332222Yes22
33112211Yes11
55——11No—

The prime 55 appears only in the factorization of 6060, so it is excluded. Multiplying the shared primes at their lowest powers gives us:

HCF(24,36,60)=22×3=4×3=12\text{HCF}(24, 36, 60) = 2^2 \times 3 = 4 \times 3 = 12

Notice that adding a third number to the set kept the HCF the same or made it smaller compared to any pair, because each new factorization adds another filter.

When This Method Really Shines

For small numbers, listing factors and comparing them is perfectly fine. The prime factorization method shows its true strength with larger numbers, where full factor lists would be long and error-prone. Consider finding the HCF of 168168 and 252252:

168=23×3×7168 = 2^3 \times 3 \times 7 252=22×32×7252 = 2^2 \times 3^2 \times 7

The shared primes are 22, 33, and 77, taken at powers 22, 11, and 11 respectively:

HCF(168,252)=22×3×7=4×3×7=84\text{HCF}(168, 252) = 2^2 \times 3 \times 7 = 4 \times 3 \times 7 = 84

We reached the answer in just a few lines — no need to list over a dozen factors for each number. Think about a scenario where a warehouse has 168 bottles of water and 252 bottles of juice and needs to pack them into the largest possible number of identical supply kits with no leftovers. The HCF tells us that 8484 kits can be made, each containing 22 waters and 33 juices. The bigger the numbers, the more time this method saves.

Conclusion and Next Steps

In this lesson, we learned how to find the HCF by comparing prime factorizations rather than full factor lists. The process comes down to three ideas: identify the primes shared by all numbers, take each shared prime at its lowest appearing power, and multiply. We also explored why primes found in only one factorization are left out and why higher powers of shared primes cannot be used, since including them would produce a number that no longer divides every value in the set.

Now it is time to put this method into practice! The upcoming exercises will walk you through guided fill-in-the-blank examples first, then challenge you with larger numbers and sets of three, so you can build real confidence with this powerful technique.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal