Problem related to-the sieve of eratosthenes

Assignment Help C/C++ Programming
Reference no: EM131608559

Question: (The Sieve of Eratosthenes) A prime integer is any integer greater than 1 that can be divided evenly only by itself and 1. The Sieve of Eratosthenes is a method of finding prime numbers. It works as follows:

a) Create an array with all elements initialized to 1 (true). Array elements with prime subscripts will remain 1. All other array elements will eventually be set to zero.

b) Starting with array subscript 2 (subscript 1 is not prime), every time an array element is found whose value is 1, loop through the remainder of the array and set to zero every element whose subscript is a multiple of the subscript for the element with value 1. For array subscript 2, all elements beyond 2 in the array that are multiples of 2 will be set to zero (subscripts 4, 6, 8, 10, and so on.). For array subscript 3, all elements beyond 3 in the array that are multiples of 3 will be set to zero (subscripts 6, 9, 12, 15, and so on.). When this process is complete, the array elements that are still set to 1 indicate that the subscript is a prime number. Write a program that uses an array of 1,000 elements to determine and print the prime numbers between 1 and 999. Ignore element 0 of the array.

Reference no: EM131608559

Questions Cloud

Wap to assign seats on each flight of the airline only plane : (Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system. The president has asked you to program.
Standardization or an international strategy : A structure is more appropriate for firms pursuing global standardization or an international strategy.
Preserves all original formatting : When creating a web query, which option preserves all original formatting?
Experience with creating a presentation recording : Discuss your experience with creating a presentation recording? How is the process going and what obstacles you faced?
Problem related to-the sieve of eratosthenes : Create an array with all elements initialized to 1 (true). Array elements with prime subscripts will remain 1. All other array elements will eventually.
Discuss the importance of services marketing : Discuss the importance of services marketing. How is services marketing unique from marketing a product or other tangible item?
Hedge the effects of fluctuations in currency : What derivative securities can be used to hedge the effects of fluctuations in currency values on the cash flows of the firms and investors?
Discuss the validity of the information presented : Find at least two (2) Web sites that would be useful for doing secondary research on a social sciences topic.
Write a recursive function test palindrome that returns one : (Palindromes) A palindrome is a string that's spelled the same way forward and backward. Some examples of palindromes are: "radar," "able was i ere i saw elba.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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