In mathematics, the Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to a specified integer.
we make a map of numbers from 1, red dot are prime, other ones are not.
You can choose the size of dot (reset with the green flag)
algorithm from wikipedia:
1. Write a list of numbers from 2 to the largest number you want to test for primality. Call this List A. (This is the list of squares on the left-hand-side of the picture.)
2. Write the number 2, the first prime number, in another list for primes found. Call this List B. (This is the list on the right-hand-side of the picture.)
3. Strike off 2 and all multiples of 2 from List A.
4. The first remaining number in the list is a prime number. Write this number into List B.
5. Strike off this number and all multiples of this number from List A. The crossing-off of multiples can be started at the square of the number, as lower multiples have already been crossed out in previous steps.
6. Repeat steps 4 and 5 until no more numbers are left in List A.
Comments
You need to be logged in to post comments
Add a Comment