Sieve of Eratosthenes
The Sieve of Eratosthenes is the oldest way to list the prime numbers. Write down the numbers from 2 to N. Take the first number that is not crossed out: it is prime. Cross out all its multiples, then take the next number that is left. Here every prime crosses out its multiples in its own colour, so you can see which prime removed which number.
How it works
- Choose how far to sieve: up to 100, 200, 500 or 1000.
- Press Play to watch the sieve run, or Step to finish one prime at a time. Space and the right arrow key work as well.
- Change the speed, or switch the numbers, the current prime, the \(p^{2}\) start and the prime count on or off. Save the grid as a PNG with the Save button.
Why start at p²?
When the sieve reaches a prime p, every smaller multiple of p, such as 2p or 3p, has already been crossed out by a smaller prime. The first multiple that is still left is \(p\times p\). That is why the dashed box marks \(p^{2}\), and why the sieve can stop as soon as \(p^{2}\) is more than N: every number that is left is then prime.
Colours
Each prime gets its own colour. A crossed-out number keeps the colour of its smallest prime factor, the prime that crossed it out first. When a prime reaches a number that is already crossed out, the number flashes but keeps its colour. So 12 stays the colour of 2, even though 3 visits it too.
Using the app
Press Play to watch each prime cross out its multiples, or Step to do one prime at a time. The numbers that are left are the primes.
Frequently asked questions
How many primes are there up to 100?
There are 25 primes up to 100, 46 up to 200, 95 up to 500 and 168 up to 1000.
Why is 1 not crossed out or coloured?
1 is not a prime number and not a composite number either, so the sieve starts at 2. 1 is shown greyed out.
Who was Eratosthenes?
Eratosthenes of Cyrene was a Greek scholar of the 3rd century BC who ran the Library of Alexandria. He is also famous for estimating the circumference of the Earth from the angle of the Sun's shadow. The sieve comes down to us through Nicomachus of Gerasa, who described it around AD 100.
Why do you only need primes up to the square root of N?
Because every composite number up to N has a prime factor no bigger than \(\sqrt{N}\): if both factors were larger, their product would be more than N. So up to 100 only 2, 3, 5 and 7 cross anything out, and up to 1000 the last one is 31. Every number left after that is prime.
埃拉托斯特尼篩法: how do I record a video?
Press the red Record button in the playback bar: it films what the stage shows. Press it again to stop, and the video is saved to your device.Recording is free; you only need to sign in. Without a subscription the video carries a small PictorX logo in a corner.The button beside Record opens the video options: the shape (as shown, square, story 9:16 or wide 16:9), the length (until you stop, or 5, 10, 15 or 30 seconds for social media) and the file: MP4, WebM or an animated GIF.You can add one of three music tracks: calm, bright or beat.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
前往編輯器