LCM Using Prime Factorisation

Introduction

Great progress so far in Finding the Lowest Common Multiple! We are already at lesson three of five in this course. Over the first two lessons, you explored common multiples and then learned how to find the LCM by listing multiples until the first shared value appeared. That listing method is clear and reliable, but it can become slow when numbers get larger. Today, you will learn a more efficient approach: finding the LCM using prime factorisation.

When Listing Reaches Its Limits

Consider trying to find LCM(48,72)\text{LCM}(48, 72) by listing. You might need to write out many multiples of each number before spotting the first match. For even bigger numbers, the lists grow quickly and the process becomes tedious.

Prime factorisation gives us a shortcut that works directly with the structure of the numbers rather than scanning long lists. As you may recall from earlier in this learning path, every whole number greater than 11 can be written as a unique product of prime factors. That breakdown is exactly the tool we will use now.

The Core Idea

Here is the key insight: for a number to be a multiple of 1212, it must contain at least the same prime factors that 1212 has, each raised to at least the same power. Since 12=22×312 = 2^2 \times 3, any multiple of 1212 needs at least two 22s and at least one 33 among its prime factors. The same logic holds for any number.

So for a number to be a common multiple of two numbers, it must carry enough prime factors to cover both. The LCM is the smallest such number, which means we take every prime that appears in any of the factorisations, each at its highest power across the numbers — nothing more, nothing less.

The Method Step by Step

Let us find LCM(12,18)\text{LCM}(12, 18) using prime factorisation. Imagine two rotating displays in a shop window: one completes a cycle every 1212 seconds, the other every 1818 seconds. To find when both displays first reset together, we need the LCM of 1212 and 1818.

Step 1 — Factorise each number.

12=22×312 = 2^2 \times 3 18=2×3218 = 2 \times 3^2 Prime factor trees for 12 and 18 showing the breakdown into 2² × 3 and 2 × 3²

Step 2 — Identify every prime that appears in any factorisation. The primes involved are 22 and 33.

Step 3 — For each prime, choose the highest power across both factorisations.

PrimePower in 1212Power in 1818Highest power
22222^2212^1222^2
33313^1323^2323^2

Step 4 — Multiply the highest powers together.

LCM(12,18)=22×32=4×9=36\text{LCM}(12, 18) = 2^2 \times 3^2 = 4 \times 9 = 36

We can verify: 36÷12=336 \div 12 = 3 and 36÷18=236 \div 18 = 2. Both results are whole numbers, confirming that 3636 is indeed a common multiple. Because we used only the minimum prime power needed to cover each number, it is the lowest common multiple. Back to our shop-window scenario — both displays first reset together after 36 seconds.

A Worked Example with Different Primes

Things get especially interesting when two numbers do not share all of their prime factors. Let us try LCM(60,72)\text{LCM}(60, 72).

Factorise:

60=22×3×560 = 2^2 \times 3 \times 5 72=23×3272 = 2^3 \times 3^2

Collect every prime: 22, 33, and 55. Notice that 55 appears only in the factorisation of 6060. We still must include it, because the LCM must be a multiple of 6060, and 6060 contains a factor of 55.

PrimePower in 6060Power in 7272Highest power
22222^2232^3232^3
33313^1323^2323^2
55515^1-515^1
LCM(60,72)=23×32×5=8×9×5=360\text{LCM}(60, 72) = 2^3 \times 3^2 \times 5 = 8 \times 9 \times 5 = 360

Quick check: 360÷60=6360 \div 60 = 6 and 360÷72=5360 \div 72 = 5. Both whole numbers, so we are good.

Extending to Three Numbers

The method scales naturally. Suppose three rotating shift schedules repeat every 88, 1212, and 1515 days. To find when all three schedules first align, we need LCM(8,12,15)\text{LCM}(8, 12, 15). Start by factorising all three:

8=23,12=22×3,15=3×58 = 2^3, \quad 12 = 2^2 \times 3, \quad 15 = 3 \times 5

The primes present are 22, 33, and 55. We pick the highest power of each across all three factorisations:

PrimePower in 88Power in 1212Power in 1515Highest
22232^3222^2-232^3
33-313^1313^1313^1
55--515^1515^1
LCM(8,12,15)=23×3×5=8×3×5=120\text{LCM}(8, 12, 15) = 2^3 \times 3 \times 5 = 8 \times 3 \times 5 = 120 Grid diagram showing prime factor powers of 8, 12, and 15 across three columns with the highest power of each prime selected and multiplied to give LCM 120

All three schedules first coincide on day 120120. The rule stays the same regardless of how many numbers you have: include every prime from every factorisation, each at its highest power.

Why Shared Primes Alone Are Not Enough

You might wonder: "Can I save time and use only the primes that the numbers have in common?" This is a natural question, especially if you recall that the Highest Common Factor (HCF) works by taking shared primes at their lowest powers. The LCM, however, goes in the opposite direction.

Consider 12=22×312 = 2^2 \times 3 and 10=2×510 = 2 \times 5. The only shared prime is 22. If we built our result from shared primes alone, we would get 22 (the HCF). Even if we took the highest power of that shared prime, 22=42^2 = 4, it would not be a common multiple. That product is far too small because it is missing the factors of 33 and 55.

Venn diagram contrasting using only shared primes versus all primes when computing the LCM of 12 and 10

The LCM must be divisible by each original number, so it needs every prime factor from every number — not just the ones they happen to share:

LCM(12,10)=22×3×5=60\text{LCM}(12, 10) = 2^2 \times 3 \times 5 = 60

Leaving out any prime that belongs to one of the numbers guarantees the result will fail to be a multiple of that number.

Conclusion and Next Steps

In this lesson, you learned a faster way to find the LCM: factorise each number into primes, select every prime that appears in any factorisation at its highest power, and multiply those together. We also explored why this approach requires all primes — omitting a prime that is unique to one number means the result cannot be a multiple of that number.

Now it is time to put this technique to work! The upcoming practice tasks will walk you through the method piece by piece: first selecting the correct highest powers, then computing full LCMs for pairs and trios of numbers, and finally explaining the reasoning in your own words. Let's build that confidence one step at a time.

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