Nepedia
Back to Discover
Fluent Reader
🔢

Sieve of Eratosthenes

math Maturity 7-9 Next article →

Prime numbers are the building blocks of math. A prime number is a whole number that has exactly two divisors. These are the number 1 and the number itself. Finding these numbers can be a hard job as numbers get larger. The Sieve of Eratosthenes is a famous way to find them. This method is called an algorithm, which is just a step-by-step way to solve a problem. It is much faster than testing every single number one by one.

Animation Sieve of Eratosth
Animation Sieve of Eratosth

To use this sieve, you first create a list of numbers. You start with the number 2 and go up to your chosen limit. The number 2 is the first prime, so you keep it. Then, you cross out all the multiples of 2. You do this by counting up by twos, like 4, 6, and 8. Next, you find the next number that is not crossed out. That number will be 3, which is your next prime. You then cross out all the multiples of 3 by counting in steps of three. You repeat this process for every new prime you find.

Animation Sieve of Eratosth
Animation Sieve of Eratosth

This clever idea is very old. It is named after Eratosthenes of Cyrene. He was a Greek mathematician who lived in the 3rd century BCE. We first read about his method in a book by Nicomachus of Gerasa. This book was written in the early 2nd century CE. Nicomachus described the method using odd numbers. Even though it is ancient, the sieve is still very useful today. It is one of the most efficient ways to find small primes.

Animation Sieve of Eratosth
Animation Sieve of Eratosth

There are ways to make the sieve work even better. One trick is to start crossing out multiples from the square of the prime. For example, if you are looking at 5, you can start at 25. This works because all smaller multiples were already marked by smaller primes. Another way is to use a segmented sieve. This is helpful when you want to find primes in a huge range. A regular sieve needs a lot of memory to hold a giant list. A segmented sieve breaks the big list into smaller parts to save space.

Animation Sieve of Eratosth
Animation Sieve of Eratosth

You can think of the sieve like a kitchen tool. A real sieve strains pasta by letting small water pass through. The math sieve strains numbers by letting composite numbers fall through. The only numbers that stay in the sieve are the primes. This method is special because it only uses addition. You do not need to use hard division to find the answers. It turns a big, messy list into a clean set of primes.

Animation Sieve of Eratosth
Animation Sieve of Eratosth
436 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (1)
File:Animation Sieve of Eratosth.gif
Animation Sieve of Eratosth.gif
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.