Simple algorithm to find all prime numbers

Assignment Help Basic Computer Science
Reference no: EM131073683

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.

Reference no: EM131073683

Questions Cloud

Little endian configurations : Part a) Explain the Big Endian and the Little Endian configurations. Part b) Show how the data (0x12AB) is stored at address 100 in either of the configurations.
Find the code memory address size : Part a) Using a Harvard design, find the code memory address size, the data memory address size and the total memory size in bits. Part b) Using a von Neumann design, find the memory address size and the total memory size in bits.
What is the total size of the memory : Part a) A memory is byte addressable and has a 12-bit address. All the addresses are valid. What is the total size of the memory?
Local area network solution : A retail department store is approximately square, 35 meters (100 feet) on each side. Each wall has two entrances equally spaced apart. Located at each entrance is a point-of-sale cash register. Suggest a local area network solution that interconn..
Simple algorithm to find all prime numbers : Eratosthenes sieve The Eratosthenes sieve is a simple algorithm to find all prime numbers less than a given number.
Sketch a parabola that models a real-life situation : Sketch a parabola that models a real-life situation and describe what the vertex represents. Determine reasonable domain and range values for this type of situation
Determing the solution of the system : Determing the solution of the system. What is the ordered pair for
Write a c program that displays your name and address : Write a C program that displays your name and address (or if you value your privacy, a fictitious name and address). Convert the following to a do/while loop. It should produce exactly the same output.
What is the equal amount in actual dollars : Assume that these college payments will be made at the beginning of each school year. The future general inflation rate is estimated to be 4% per year, and the annual inflation-free interest rate is 5%. What is the equal amount, in actual dollars, Je..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Access control system

What access control system is most valuable for protecting enterprise systems? Why? What are two specific strengths and two specific drawbacks for your chosen access control system?

  Which files match with the pattern file[abc]

which files match with the pattern " file[ABC] "

  How you can achieve the desired telnet effect

Now suppose your firewall is allowed to use the TCP header Flags bits in addition to the port numbers. Explain how you can achieve the desired Telnet effect here while at the same time allowing no inbound TCP connections.

  What security threats from social networking

What security  threats from social networking  also apply to other businesses? Which do not? Why do you think so?

  Should multiply a numeric variable named number

Code a while statement that will continue executing while a variable named multiplier is not equal to 1. The code within the while loop should start by subtracting 1 from the multiplier variable.

  Convert the cfg to chomsky normal form

convert the CFG to Chomsky Normal Form(CNF). convert this CFG to one with-out the lambda-Production then....

  Write a program to perform grocery check-out procedure

Write a program to perform grocery check-out procedure for a simple store. Use a dynamic array of structures (Up to 100) to store this information. For each product we store the following information.

  Create a powerpoint presentation on a person that admire you

Select a person that you admire the most. The person can be a family member, friend, musician, etc. Create a four (4) slide PowerPoint presentation

  Create the users for the sales organization unit

Explain how you would create the users for the sales organization unit and how you can set up work groups in this particular situation

  Create each thread as its arrival time comes

Create each thread as its arrival time comes, keep it in working state and terminate as the CPU time finishes.

  Evaluate online tutorials and online communities

Ray and Jason have just finished developing the documentation for a system your team recently completed. Ray insists that the documentation should be printed in booklet format and included with the system.

  Demand function

Whe the price of meat Rp 30.000,00 / kg, the amount demanded 50 kg. At the time the price rose to USD 40,000.00 / kg the amount requested to be 30 kg. Demand function is

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd