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

  Write relational algebra expression itinerary detailed dates

Write down the relational algebra expressions for given transactions. When viewing appointments have been made, itinerary has to be given detailing dates.

  Confirm the presence of malware on a system

Show five types of system information that can be obtained from the Windows Task Manager? Show how can you use this information to confirm the presence of malware on a system?

  Briefly describe the threat

This assignment provides you with an opportunity to read an article about a current security threat (or attack) while also examining how security measures impact the customer experience.

  Minimum number of edits required to convert string

Given two strings of size m, n and set of operations replace (R), insert (I) and delete (D) all at equal cost. Find minimum number of edits (operations) required to convert one string into another.

  Why are computers equipped with multiple layers of cache

Why are computers equipped with multiple layers of cache? Would it not be better to simply have one big one? What is the average access time?

  What makes up the legislative body

What makes up the legislative body and what does the central bank do?

  Assess and evaluate key aspects of legal

Identify ethical, social and legal issues relevant to Information Systems within a context of application and assess and evaluate key aspects of legal, ethical and cultural issues relevant to an IT professional

  Write a recursive program spaces

Write a recursive program spaces(s) that takes as input a string s and returns the number of blank spaces (that is, ' ') the string s contains. You may not use string functions such as count, replace, etc. (slicing is ok), and loops and global variab..

  Design a spreadsheet to understand required funds

Using the parameters in (a), construct a graph showing how the amount required for the order would vary if the unit cost of a package of bandages rose by $0.25, $0.50, and so on, up to $3.00 per package.

  Explain java data streams

Explain Java data streams. How do we move different types of data from one place to another in Java. What different types of data streams are there?

  The disadvantages of allowing unlimited access

Employers can use a number of products to monitor their employees' use of the Internet. These products report an employee's access of non-business related Web sites. Advocates insist that these products conserve network resources, make workers mor..

  Returns the bottom of the stack instead of the top

This function returns the bottom of the Stack instead of the top

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