Question: Java Programming Course: Write a Primes program that finds prime numbers using the Sieve of Eratosthenes, an algorithm devised by a Greek mathematician of the

Java Programming Course:

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 describe by the following psuedocode:

create a queue of numbders to process. fill the queue with the intergers 2 through n inclusive. create an empy 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 resule queue or primes. loop through the queue of number, elimintating all numbers that are divisible by p. while (p ie less than the square root of n).

all remaining values in the numbers queue are prime, so transfer them to the result primes queue.

Wikipedia has a nice description and animation of this algorithm in action: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!