Prime and Composite Numbers

Introduction

You have reached the final lesson of **Foundations of Factors and Multiples ** — and it is the one that gives the course its name. Over the first three lessons, you mastered factors, factor pairs, complete factor lists, and multiples. Each of those skills was a stepping stone leading here.

Now we put them to work. In this lesson, we will sort every whole number greater than 11 into one of two categories — prime or composite — based on how many factors it has. We will also settle the question of where 11 belongs and discover why prime numbers earn the title of "building blocks" for all other numbers.

A Quick Look Back at Factor Counts

Recall from Lesson 2 that every whole number has a complete factor list. Some lists are short and some are long. Let's line up a few familiar examples:

NumberComplete factor listHow many factors?
221,21, 222
771,71, 722
12121,2,3,4,6,121, 2, 3, 4, 6, 1266
15151,3,5,151, 3, 5, 1544
111111

Notice the pattern: some numbers have exactly two factors, others have many more, and 11 stands alone with just one. That difference in factor count is precisely what separates prime numbers from composite numbers, and it is the focus of everything that follows.

Prime Numbers

A prime number is a whole number greater than 11 that has exactly two factors: 11 and the number itself. No other whole number divides it evenly.

Consider 1313. If we test every whole number from 22 up to 1212, none of them divides 1313 without a remainder. The only factors are 11 and 1313, giving us exactly two, so 1313 is prime. The first several prime numbers are:

2,  3,  5,  7,  11,  13,  17,  19,  23,  29,  …2,\; 3,\; 5,\; 7,\; 11,\; 13,\; 17,\; 19,\; 23,\; 29,\; \ldots Color-coded number grid from 1 to 30 classifying each number as prime, composite, or neither

A couple of things worth noting. First, 22 is the smallest prime and also the only even prime, because every other even number is divisible by 22 and therefore has at least three factors. Second, being prime is not about being odd or "looking special." It comes down to one simple test: does the number have exactly two factors?

Composite Numbers

A composite number is a whole number greater than 11 that has more than two factors. That means at least one whole number besides 11 and the number itself divides it evenly.

Take 1818. Its complete factor list is 1,2,3,6,9,181, 2, 3, 6, 9, 18 — six factors in total. Since that is more than two, 1818 is composite. Here are a few more examples:

NumberFactorsFactor countClassification
441,2,41, 2, 433Composite
991,3,91, 3, 933Composite
20201,2,4,5,10,201, 2, 4, 5, 10, 2066Composite
25251,5,251, 5, 2533Composite

Every composite number has at least one factor pair beyond the guaranteed pair of 11 and the number itself. For instance, 20=4×520 = 4 \times 5, so 44 and 55 are factors that make 2020 composite. If you ever find even one factor other than 11 and the number, you can stop — the number is composite.

Where Does 1 Fit?

The number 11 is a common source of confusion. It might feel like a prime because it cannot be broken into smaller whole-number factors. However, recall the definition: a prime must have exactly two factors. The only factor of 11 is 11 itself, so its factor count is just one.

Because 11 has fewer than two factors, it does not qualify as prime. And because it does not have more than two factors, it is not composite either. Mathematicians therefore classify 11 as neither prime nor composite — a special case we will revisit at the end of the lesson when we see why this choice matters.

Diagram showing the number 1 standing apart from the prime and composite categories

Checking Larger Numbers

For small numbers like 22 through 1010, you can probably classify them from memory. But what about a number like 3131 or 3939? The technique is the same systematic approach from Lesson 2: test potential factors starting from 22.

Let's check 3939. We try 22: since 3939 is odd, 22 does not divide it. We try 33: 39÷3=1339 \div 3 = 13 with no remainder. We found a factor other than 11 and 3939, so 3939 is composite — no need to keep testing.

Now let's check 3131. We test 22 (no, 3131 is odd), 33 (31÷3=1031 \div 3 = 10 remainder 11), 44 (skip — if 22 didn't work, 44 won't either), and 55 (3131 does not end in 00 or 55) — none divide evenly. Because 6×6=36>316 \times 6 = 36 > 31, we only needed to test up to 55; once the test factor squared exceeds the number, any remaining factor pair would already have been found. So 3131 is prime.

This shortcut saves real work with bigger numbers. To check whether 9797 is prime, for instance, you only need to test 2,3,4,5,6,7,8,92, 3, 4, 5, 6, 7, 8, 9 — because 10×10=100>9710 \times 10 = 100 > 97.

Actually, you only need to test the prime numbers below that limit (2,3,5,72, 3, 5, 7). You can skip 4,6,84, 6, 8, and 99 because if 22 didn't divide 9797, then no multiple of 22 (like 4,64, 6, or 88) will divide it either. This makes the prime test even faster! After confirming none of those primes divide 9797 evenly, you know it is prime.

Primes as Building Blocks

Here is the most important idea in this lesson. Every composite number can be written as a product of prime numbers. Let's see this in action with 6060:

60=2×3060 = 2 \times 30

The factor 3030 is still composite, so we split it further:

60=2×2×1560 = 2 \times 2 \times 15

And 1515 is also composite:

60=2×2×3×560 = 2 \times 2 \times 3 \times 5

Now every factor in the product (2,2,3,52, 2, 3, 5) is prime, and the process stops. It must stop, because a prime number cannot be split into smaller whole-number factors. That is exactly what makes primes irreducible: they are the endpoint of any splitting process.

Factor tree diagram showing 60 broken down step by step into its prime factors 2 × 2 × 3 × 5

Think of it like building with LEGO bricks. Composite numbers are the assembled structures — they can always be taken apart into smaller pieces. Primes are the individual bricks that cannot be broken down any further. No matter what composite number you start with, the breaking-apart process always ends at primes.

This idea has a formal name: the Fundamental Theorem of Arithmetic. It states that every whole number greater than 11 is either prime itself or can be expressed as a product of primes in exactly one way (apart from rearranging the order). This is also why 11 is excluded from the primes — if 11 were considered prime, we could slip as many 11s as we like into any product, and the "exactly one way" guarantee would fall apart.

Conclusion and Next Steps

In this lesson, you classified every whole number greater than 11 as prime (exactly two factors) or composite (more than two factors) and established that 11 is neither. You also discovered the deeper reason primes matter: they are the irreducible pieces from which every composite number is built, a principle captured by the Fundamental Theorem of Arithmetic.

Now it is time to put your understanding to the test. In the practice exercises ahead, you will classify numbers on sight, sort them into prime and composite groups, hunt for primes in unfamiliar ranges, and break a composite number all the way down to its prime building blocks. Jump in and see how solid your number sense has become!

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