Prime Numbers Explained: What They Are and How to Find Them

Number Challenges guide · 6 min read

Prime numbers are the building blocks of arithmetic, the numbers from which every other whole number is made. A prime number is a whole number greater than 1 that has exactly two divisors: 1 and itself. That simple definition leads to some of the deepest ideas in mathematics and to a lot of satisfying puzzles. This guide explains what prime numbers are, why 1 doesn't count, how to test whether a number is prime, and where primes show up in the real world. They're also central to the harder number challenges, so knowing them well pays off.

What is a prime number?

A prime number is a whole number greater than 1 whose only divisors are 1 and itself. It can't be split into a product of two smaller whole numbers. The first prime numbers are:

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, ...

A whole number greater than 1 that isn't prime is called composite, because it's composed of smaller factors. For example, 12 is composite because 12 = 3 × 4. The number 2 is the only even prime, every other even number is divisible by 2 and so has 2 as a factor.

Why isn't 1 a prime number?

This trips a lot of people up. The number 1 is not prime (and not composite either, it's in a category of its own). The reason is partly definitional and partly practical: a prime must have exactly two divisors, and 1 has only one (itself). Excluding 1 also keeps an important rule clean, the fact that every number factors into primes in exactly one way. If 1 were prime, you could write 6 as 2 × 3 or 1 × 2 × 3 or 1 × 1 × 2 × 3, and that uniqueness would break.

How to test if a number is prime

To check whether a number is prime, you only need to test for small divisors, and you can stop sooner than you'd think.

The key shortcut: you only have to check for factors up to the square root of the number. If a number has a factor larger than its square root, it must also have one smaller than the square root, so testing the small ones is enough.

Example: is 97 prime? Its square root is about 9.8, so you only check the primes up to 9: 2, 3, 5, 7. 97 is odd (not divisible by 2), its digits sum to 16 (not divisible by 3), it doesn't end in 0 or 5, and 97 ÷ 7 isn't whole. No factor works, so 97 is prime.

Example: is 91 prime? It looks prime, but check 7: 91 = 7 × 13. So 91 is composite, a classic trap. Your divisibility rules make these checks fast.

The Sieve of Eratosthenes

To find all the primes up to some limit, the classic method is the Sieve of Eratosthenes, an algorithm over 2,000 years old. It works like this:

  1. Write out all the numbers from 2 up to your limit.
  2. Circle 2 (the first prime), then cross out every multiple of 2.
  3. Move to the next uncrossed number (3), circle it, and cross out every multiple of 3.
  4. Repeat: the next uncrossed number is always prime; circle it and cross out its multiples.
  5. When you've processed numbers up to the square root of your limit, every remaining uncrossed number is prime.

It's a beautifully simple way to sieve out the primes, and it's still the go-to method for listing primes by hand or in code.

Two facts that make primes fascinating

  • There are infinitely many primes. The ancient Greek mathematician Euclid proved this with a clever argument: if you had a complete list of primes, you could multiply them all together and add 1, producing a number that no prime on your list divides evenly, a contradiction. So the list can never be complete.
  • Every whole number above 1 factors into primes uniquely. This is the Fundamental Theorem of Arithmetic. For example, 360 = 2 × 2 × 2 × 3 × 3 × 5, and there's no other way to break it into primes. This is why primes are called the building blocks of numbers.

Where prime numbers are used

Primes aren't just abstract curiosities. They underpin modern cryptography: systems like RSA, which secures much of online communication, rely on the fact that multiplying two huge primes is easy but factoring the result back into those primes is extremely hard. The search for ever-larger primes is also an ongoing project, the largest known primes are Mersenne primes (of the form 2ⁿ − 1) with tens of millions of digits, found by a worldwide distributed-computing effort.

Primes in number puzzles

In number puzzles, primes show up constantly: as the answer to "which of these is prime," as a hidden structure in a sequence (the sequence of primes itself, 2, 3, 5, 7, 11, looks irregular until you recognise it), or as a constraint in a number theory puzzle. Being able to recognise small primes on sight, and quickly test slightly larger ones, removes a lot of friction.

Learn the first dozen primes by heart, master the square-root test, and primes stop being mysterious. Then put them to work on a number challenge.

Frequently asked questions

What is a prime number?

A prime number is a whole number greater than 1 that has exactly two divisors: 1 and itself. It can't be made by multiplying two smaller whole numbers. The first primes are 2, 3, 5, 7, 11, 13, and so on. A number greater than 1 that isn't prime is called composite.

Is 1 a prime number?

No. The number 1 is neither prime nor composite. A prime must have exactly two distinct divisors, and 1 has only one (itself). Excluding 1 also keeps prime factorisation unique, which is why mathematicians define it this way.

How do you find out if a number is prime?

Test whether it's divisible by any prime up to its square root. If none divides it evenly, it's prime. For example, to check 97 you only need to test 2, 3, 5, and 7 (since √97 ≈ 9.8); none works, so 97 is prime.

What is the Sieve of Eratosthenes?

It's an ancient method for finding all primes up to a limit. You list the numbers, then repeatedly take the next uncrossed number as a prime and cross out all its multiples. Whatever remains uncrossed at the end is the complete list of primes up to your limit.