Awesome
Sieve of Eratosthenes
What is it?
In mathematics, the sieve of Eratosthenes, one of a number of prime number sieves, is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e., not prime) the multiples of each prime, starting with the multiples of 2. <br> -- https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
In Motion
In Words
- Start with an array of integers from 2 to N.
- Cross out all the elements that are divisible by the primes known so far.
- The first element of array is the next prime.
See sieve.rb.
- If the first element of array is larger than the square root of N, all the remaining elements must be prime.
See beter_sieve.rb.
There is a Sculpture!
The Sieve of Eratosthenes, 1999 sculpture by Mark di Suvero. Displayed at Stanford University:
CC0 1.0 Universal
To the extent possible under law, @JuanitoFatas has waived all copyright and related or neighboring rights to "sieve_of_eratosthenes".