Eratosthenes sieve
The Eratosthenes sieve is a simple algorithm to find all prime numbers less than a given number.
It proceeds as follow:
- make a collection of numbers between 2 and the given number (let's call it allNumbers)
- make an empty collection that will receive all the prime numbers (let's call it allPrimes)
- repeat until allNumbers is empty the following steps
- remove the first element of allNumbers, call it prime, and put it in allPrimes
- remove all multiple of prime from allNumbers
- print all numbers from allPrimes
Implement this algorithm choosing appropriately what collections from the java.util package can be best for allNumbers and allPrimes.
Explain your choices in your documentation.
The deliverables are one Java class, allowing to run the sieve by passing the maximum number on the command line, the design document (no more than one page) explaining the choice of data structures, and a test document explaining how you check the correctness of your program.