Question: Write a Primes program that finds prime numbers using the Sieve of Eratosthenes, an algorithm devised by a Greek mathematician of the same name who
Write a Primes program that finds prime numbers using the Sieve of Eratosthenes, an algorithm devised by a Greek mathematician of the same name who lived in the third century BC. The algorithm finds all prime numbers up to some maximum value n, as described by the following pseudocode:

Several web sites have nice descriptions and animations of this algorithm in action; consider searching for “Sieve of Eratosthenes” in your web browser.
create a queue of numbers to process. fill the queue with the integers 2 through n inclusive. create an empty result queue to store primes. repeat the following steps: obtain the next prime p by removing the first value from the queue of numbers. put p into the result queue of primes. loop through the queue of numbers, eliminating all numbers that are divisible by p. while (p is less than the square root of n). all remaining values in the numbers queue are prime, so transfer them to the result primes queue.
Step by Step Solution
3.44 Rating (173 Votes )
There are 3 Steps involved in it
public class MySolution void MySolutionint n ... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (2 attachments)
2079_60f58f34f28fc_856965.pdf
180 KBs PDF File
2079_60f58f34f28fc_856965.docx
120 KBs Word File
