Home » Math Theory » Numbers » Prime Numbers

Prime Numbers

Quick answer

A prime number is a whole number greater than 1 whose only factors are 1 and itself. The prime numbers start 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. A whole number greater than 1 with more than two factors is composite (for example 9 = 3 × 3). The number 1 is neither prime nor composite, and 2 is the only even prime.

Reviewed by the Helping with Math Team · Updated 14 October 2026

Introduction

Number theory is the part of math that studies whole numbers. People have explored it since ancient times, mostly with natural numbers. You may know the Pythagorean theorem and Pythagorean triples; prime numbers are another classic topic, and some questions about them are still unsolved today.

Prime and composite numbers

A prime number is a natural number greater than 1 that can be divided evenly only by 1 and by itself. A natural number greater than 1 that can be divided evenly by some other number too is a composite number.

A factor of a number divides it with no remainder. So a prime has exactly two factors, and a composite number has more than two.

  • 1 has only one factor (itself), so it is neither prime nor composite.
  • 2 is the smallest prime and the only even prime: every other even number can be divided by 2.

Example: Sort 7, 17, 27, 43, 53, 63, 73 and 77 into primes and composites.

Solution: Look for a factor other than 1 and the number: 27 = 3 × 9, 63 = 7 × 9 and 77 = 7 × 11, so these are composite. Trying every possible divisor shows that 7, 17, 43, 53 and 73 have no other factor, so they are prime.

Prime numbersComposite numbers
7, 17, 43, 53, 7327, 63, 77

Checking a number like 43 by trial division takes a while. The next section shows a faster way to find many primes at once.

The Sieve of Eratosthenes

About 2,200 years ago the Greek scholar Eratosthenes invented a simple way to list all the primes up to any number. It is called the Sieve of Eratosthenes, because it “sifts out” the composite numbers.

To find all prime numbers up to 100:

  1. Write the numbers 2 to 100 in a grid.
  2. Circle 2, then cross out every other multiple of 2 (4, 6, 8, …).
  3. Circle the next number not crossed out, 3, and cross out its multiples (6, 9, 12, …). Skip numbers already crossed out.
  4. Circle 5 and cross out its multiples, then do the same for 7.
  5. Stop there: 11 × 11 = 121 is bigger than 100, so every composite number up to 100 has already been crossed out. Everything left is prime.
Sieve of Eratosthenes for 1 to 100 with the 25 primes circled123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
After crossing out the multiples of 2, 3, 5 and 7 (shown in gray), the 25 numbers left (circled) are the primes below 100. 1 is gray too, because it is not prime.

The sieve leaves the 25 primes below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97.

Prime numbers up to 1,000

Sieving further gives the primes up to 1,000. There are 168 of them.

RangePrime numbers
1 to 992, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
100 to 199101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199
200 to 299211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293
300 to 399307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397
400 to 499401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499
500 to 599503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599
600 to 699601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691
700 to 799701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797
800 to 899809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887
900 to 999907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997

A table makes it easy to tell whether a number below 1,000 is prime or composite: if it is in the table it is prime, and if it is not, it is composite.

For example, 677 is prime (it is in the table) and 899 is composite (it is not). 899 is tricky to check by hand because its smallest factor is fairly large: 899 = 29 × 31.

How many prime numbers are there?

There are infinitely many prime numbers. Euclid proved this about 2,300 years ago, and his argument is short.

Suppose there were only a few primes, 2, 3, 5, …, n, with n the biggest. Multiply them all and add 1: m = 2 × 3 × 5 × … × n + 1.

  • Dividing m by 2 leaves remainder 1, because the product is a multiple of 2.
  • Dividing m by 3 leaves remainder 1, and so on for every prime up to n.

So none of the primes on the list divides m. But m is bigger than 1, so it has at least one prime factor, and that prime is not on the list. Either m is itself a new prime, or it has a new prime factor. Either way the list was not complete, so the primes never run out.

For example, 2 × 3 × 5 × 7 × 11 × 13 + 1 = 30,031 = 59 × 509. It is not prime, but its prime factors 59 and 509 are new.

Gaps between prime numbers

Look at the table and you will see some big gaps between neighboring primes. There are 11 composite numbers between 509 and 521, and 13 between 839 and 853. Can the gaps be as long as we like? Yes.

Take a number n and use n! (“n factorial”) = 1 × 2 × 3 × … × n. Now look at the n − 1 numbers n! + 2, n! + 3, …, n! + n.

  • n! + 2 can be divided by 2, because both n! and 2 can.
  • n! + 3 can be divided by 3.
  • …
  • n! + n can be divided by n.

So all n − 1 of these numbers in a row are composite. Pick n big enough and you get a run of composites as long as you want.

Properties of prime numbers

The fundamental theorem of arithmetic: every whole number greater than 1 can be written as a product of primes in exactly one way, apart from the order of the factors. For example, 60 = 2 × 2 × 3 × 5. Finding these primes is called prime factorization. Three useful facts follow.

Property 1: every whole number greater than 1 has at least one prime factor. If it is prime, that factor is the number itself; if it is composite, it splits into primes.

Property 2: every composite number n has a prime factor no bigger than √n.

Why: write n = a × b with both factors bigger than 1. If both were bigger than √n, then a × b would be bigger than √n × √n = n, which is impossible. So one factor is at most √n, and so is any prime factor of it.

This saves a lot of work: to test whether n is prime, you only need to try dividing by the primes up to √n. For 97, √97 is about 9.8, so you try only 2, 3, 5 and 7.

Prime number checker

899 is composite. Its smallest prime factor is 29 (899 ÷ 29 = 31). Prime factorization: 29 × 31.

Try it: type a whole number. The checker divides by 2, 3, 5, 7, … up to the square root, then shows whether the number is prime and its prime factorization.

Property 3 (Euclid’s lemma): if a prime p divides a product a × b, then p divides a or p divides b (or both).

Why: suppose p divides neither a nor b. Then the greatest common factor of a and p is 1, so there are whole numbers s and t with sa + tp = 1. In the same way, xb + yp = 1 for some x and y. Multiply the two equations: (sa + tp)(xb + yp) = 1, which can be written as (sx)ab + (sya + txb + typ)p = 1. If p divided ab, it would divide the left side, so p would divide 1, which is impossible.

Example: 27,405 ends in 5, and its digit sum 2 + 7 + 4 + 0 + 5 = 18 is a multiple of 9, so by the divisibility rules it can be divided by 5 and by 9: 27,405 = 5 × 9 × 609.

Patterns with prime numbers

People have long looked for a formula that gives only primes, or for patterns in where primes appear.

Fact 1: Leonhard Euler noticed that x2 + x + 41 is prime for every whole number x from 0 to 39. For example, x = 13 gives 169 + 13 + 41 = 223, and x = 24 gives 576 + 24 + 41 = 641, both in the table.

It fails at x = 40: 1,600 + 40 + 41 = 1,681 = 41 × 41. In fact, no polynomial (other than a constant) gives only prime values. And x2 + x + p does not always work: for x2 + x + 47 and x = 12, the value is 144 + 12 + 47 = 203 = 7 × 29.

Fact 2: every prime bigger than 3 is one more or one less than a multiple of 6, so it has the form 6n − 1 or 6n + 1. For example, 7 = 6 + 1, 11 = 12 − 1, 41 = 42 − 1, 97 = 96 + 1, 619 = 618 + 1 and 941 = 942 − 1.

Why: any whole number is 6n, 6n + 1, 6n + 2, 6n + 3, 6n + 4 or 6n + 5. The forms 6n, 6n + 2 and 6n + 4 are even, and 6n + 3 is a multiple of 3, so a prime above 3 must be 6n + 1 or 6n + 5 (which is the same as 6n − 1). The reverse is not true: 25 = 24 + 1 is not prime.

Pattern 1: write 1 to 100 in six columns. The primes 2 and 3 sit at the top of their columns, and every other prime falls in just two columns: the one starting with 5 (6n − 1) and the one starting with 7 (6n + 1).

Numbers 1 to 102 in six columns with the primes in bold6n + 16n − 1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
In six columns, every prime after 2 and 3 lands in the column under 5 (6n − 1) or the column under 1 and 7 (6n + 1). Not every number in those columns is prime: 25, 35, 49 and 77 are not.

Pattern 2: in 1963, while doodling during a dull talk, Stanislaw Ulam wrote the numbers in a spiral and marked the primes. Many of them lined up along diagonals. This picture is now called the Ulam spiral. With thousands of numbers, the diagonal lines become very clear.

Ulam spiral of the numbers 1 to 100 with primes shaded123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
The Ulam spiral: start with 1 in the middle and wind outward. The shaded primes tend to line up on diagonals, for example 5, 19, 41, 71.

Primes are good at drawing patterns. Try making your own with the grid and spiral below.

Prime number practice questions

1. Which of these numbers are prime: 2322, 3407, 7777?

Solution: 2322 is even, so it is composite. 7777 = 7 × 1111, so it is composite. For 3407, √3407 is about 58.4, so try the primes up to 58:

3407 ÷ 2 = 1703 R 1, ÷ 3 = 1135 R 2, ÷ 5 = 681 R 2, ÷ 7 = 486 R 5, ÷ 11 = 309 R 8, ÷ 13 = 262 R 1, ÷ 17 = 200 R 7, ÷ 19 = 179 R 6, ÷ 23 = 148 R 3, ÷ 29 = 117 R 14, ÷ 31 = 109 R 28, ÷ 37 = 92 R 3, ÷ 41 = 83 R 4, ÷ 43 = 79 R 10, ÷ 47 = 72 R 23, ÷ 53 = 64 R 15.

None divides evenly. Answer: 3407 is prime; 2322 and 7777 are composite.

2. Find 12 composite numbers in a row.

Solution: n! + 2 to n! + n gives n − 1 composites, so take n = 13. 13! = 6,227,020,800, so the 12 numbers 6,227,020,802 to 6,227,020,813 are all composite. A smaller answer comes from the table: the 13 numbers 840 to 852, between the primes 839 and 853, are all composite. The factorial method works for any length.

3. Find the smallest n for which n2 − n + 17 is composite.

Solution: try n = 1, 2, 3, …: the values 17, 19, 23, 29, 37, 47, 59, 73, 89, 107, 127, 149, 173, 199, 227 and 257 are all prime. At n = 17 the value is 172 − 17 + 17 = 289 = 17 × 17. Answer: n = 17.

4. If p is prime, can p, p + 3 and p + 6 all be prime?

Solution: if p = 2, the numbers are 2, 5 and 8, and 8 is composite. If p is an odd prime, then p + 3 is even and bigger than 2, so it is composite. Answer: no.

5. If p is a prime bigger than 2, show that p2 − 9 can be divided by 8.

Solution: p2 − 9 = (p − 3)(p + 3). Since p is odd, p − 3 and p + 3 are both even. Among the consecutive even numbers p − 3, p − 1, p + 1 and p + 3, every second one is a multiple of 4. So either p − 3 or p + 3 is a multiple of 4, and the other is even. The product therefore has a factor 4 × 2 = 8. Check: p = 7 gives 49 − 9 = 40 = 8 × 5.

Key facts and summary

  1. A prime number has exactly two factors: 1 and itself.
  2. A composite number has more than two factors.
  3. 1 is neither prime nor composite.
  4. 2 is the smallest prime and the only even prime.
  5. To test n, divide only by the primes up to √n.
  6. There are infinitely many primes, and gaps between them can be as long as you like.
  7. Some famous questions about primes are still open; the Riemann hypothesis carries a $1,000,000 prize.
  8. Primes keep online banking and messages safe: modern encryption relies on how hard it is to factor very large numbers.

More practice: prime and composite numbers 4th grade worksheets.

Prime numbers FAQs

What are the first 10 prime numbers?

2, 3, 5, 7, 11, 13, 17, 19, 23 and 29.

Is 1 a prime number?

No. A prime needs exactly two factors, and 1 has only one. It is neither prime nor composite.

Is 2 a prime number?

Yes. Its only factors are 1 and 2. It is the smallest prime and the only even prime.

How do you check if a number is prime?

Divide it by each prime up to its square root. If none divides evenly, the number is prime. For 97, try 2, 3, 5 and 7.

Is 899 a prime number?

No. 899 = 29 × 31, so it is composite.

How many prime numbers are there below 100?

There are 25 primes below 100, and 168 below 1,000.

Practice with worksheets

Link/Reference Us

We spend a lot of time researching and compiling the information on this site. If you find this useful in your research, please use the tool below to properly link to or reference Helping with Math as the source. We appreciate your support!

  • "Prime Numbers". Helping with Math. Accessed on November 18, 2026. https://helpingwithmath.com/prime-numbers/.

  • "Prime Numbers". Helping with Math, https://helpingwithmath.com/prime-numbers/. Accessed 18 November, 2026.

  • Prime Numbers. Helping with Math. Retrieved from https://helpingwithmath.com/prime-numbers/.