Charting Prime Numbers using the Sieve of Eratosthenes
The Sieve of Eratosthenes is an ancient, yet efficient method of determining primes numbers in a given set of consecutive numbers (e.g. from 1 to 100).
The Sieve of Eratosthenes works starts at 2 (the first prime), which is marked as prime. Then, eliminate all multiples of 2 across the set (mark these as non-prime). Once complete, locate the next highest available number (3), which will be the next prime, and then again eliminate all multiples of 3. 4 has already been eliminated (because it was as marked prime when marking multiples of 2), so the next prime is 5. Mark off all multiples of 5, and continue this way until all numbers in the set have been processed.
By systematically working upwards through the set, all numbers which are not eliminated in this manner are prime.