A prime number is any integer greater than 1 that is evenly divisible only by itself...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A prime number is any integer greater than 1 that is evenly divisible only by itself and 1. The sieve of Eratosthenes is a method of finding prime numbers. It operates as follows: (a) Create a boolean array with all elements initialized to true.Array elements with prime indices will remain true. All other array elements will eventually be set to false. (b) Starting with array index 2, determine whether a given element is true. If so, loop through the remainder of the array and set to false every element whose index is a multiple of the index for the element with value true. For array index 2, all elements beyond element 2 in the array that have indices which are multiples of 2 (indices 4, 6, 8, 10, etc.) will be set to false; for array index 3, all elements beyond element 3 in the array that have indices which are multiples of 3 (indices 6, 9,12,15, etc.) will be set to false; and so on. When this process completes, the array elements that are still true indicate that the index is a prime number. These indices can be displayed. Write an application that uses an array of 1,000 elements to determine and display the prime numbers between 2 and 999. Ignore array elements 0 and 1. A prime number is any integer greater than 1 that is evenly divisible only by itself and 1. The sieve of Eratosthenes is a method of finding prime numbers. It operates as follows: (a) Create a boolean array with all elements initialized to true.Array elements with prime indices will remain true. All other array elements will eventually be set to false. (b) Starting with array index 2, determine whether a given element is true. If so, loop through the remainder of the array and set to false every element whose index is a multiple of the index for the element with value true. For array index 2, all elements beyond element 2 in the array that have indices which are multiples of 2 (indices 4, 6, 8, 10, etc.) will be set to false; for array index 3, all elements beyond element 3 in the array that have indices which are multiples of 3 (indices 6, 9,12,15, etc.) will be set to false; and so on. When this process completes, the array elements that are still true indicate that the index is a prime number. These indices can be displayed. Write an application that uses an array of 1,000 elements to determine and display the prime numbers between 2 and 999. Ignore array elements 0 and 1.
Expert Answer:
Answer rating: 100% (QA)
public class test public static void mainString args boolean fl... View the full answer
Related Book For
Discrete Mathematics and Its Applications
ISBN: 978-0073383095
7th edition
Authors: Kenneth H. Rosen
Posted Date:
Students also viewed these accounting questions
-
The Java programming language is referred to by some as the language of the Web, due to its platform independent nature. Java uses a hybrid form of RPC and CORBA called RMI (Remote Method...
-
In an object-oriented programming language like Java or C++, how can a program cause a value to be stored into a private variable inside of a different object? Another way to think about this is that...
-
Describe three features that make Java a better programming language than C to write secure programs.
-
Find each limit in Problems 3760. Note that LHpitals rule does not apply to every problem, and some problems will require more than one application of LHpitals rule. lim x 3 x + 3xx - 3 X x + 6x + 9
-
On January 27, 2011, the price of Ford Motor Company stock hit an almost 10-year high at $18.79 per share. (Two years prior, in January 2009, Ford stock was trading for about a tenth of that price.)...
-
(a) How much energy is transformed by a typical 65-kg person who runs at 15 km/h for 30 min/day in one week (Table 15-2)? (b) How many food calories would the person have to eat to make up for this...
-
Give some examples of variables for which the body maintains homeostasis.
-
The installed cost of a new computerized controller was $65,000. Calculate the depreciation schedule by year assuming a recovery period of 5 years and using the appropriate MACRS depreciation...
-
Asked bytoriweinreis12 If the total on the schedule of accounts receivable and the Accounts Receivable balance in the general ledger do not agree, the error a. could be in the total of the schedule,...
-
Emerald City Umbrellas sells umbrellas and rain gear in Seattle, so its sales are fairly level across the year. However, it is branching out to other markets where it expects demand to be much more...
-
Go to this link http://www.engineeringchallenges.org/challenges/informatics.aspx and listen to the related videos on the right side. They are very short, only 1-2 minutes. Write a reaction paragraph...
-
Two partners each have a 50% interest in the partnership's capital and profits. The December 31, Year 3, balance sheet for the partnership is listed below. Adjusted Basis Fair Market Value Cash $...
-
What happens when the EIGRP Hold Timer expires before receiving a Hello packet from a router Explain.
-
Charla is at the end of the third year of a five-year investment. Charla initially invested $3,000. Over the past three years, her investment rates of return were -4.25%, -4% and 2.75% respectively....
-
The report given by a network administrator says that the port status on a router interface is shown as "secure-down". What does it mean? Explain.
-
On October 1, 2023 Brooks Corp (a calendar year end corporation) purchased $750 worth of supplies. Prior to the purchase, the beginning balance in supplies was $0. On December 31, 2023 a physical...
-
Charlie's Computer Correction Connection (C4) runs a chain of computer repair franchises and has been growing rapidly. C4's stock sells for $41 per share and has 220,000 shares outstanding. C4 is a...
-
It is possible to investigate the thermo chemical properties of hydrocarbons with molecular modeling methods. (a) Use electronic structure software to predict cHo values for the alkanes methane...
-
A chain letter starts with a person sending a letter out to 10 others. Each person is asked to send the letter out to 10 others, and each letter contains a list of the previous six people in the...
-
1. Showthat there is a nonnegative integer n such that the set of n-equivalence classes of states of M is the same as the set of (n + 1)-equivalence classes of states of M. Then show for this integer...
-
Write the deferred acceptance algorithm in pseudocode.
-
Example 17.5 showed that a thin film whose thickness is one quarter of the wavelength of light in the film serves as an antireflection coating when coated on glass. In Example 17.5, \(n_{\text {film...
-
Give a specific example of a process that has the energy changes and transfers described. (For example, if the question states " \(\Delta E_{\mathrm{th}}>0, W=0\)," you are to describe a process that...
-
Give a specific example of a process that has the energy changes and transfers described. (For example, if the question states " \(\Delta E_{\mathrm{th}}>0, W=0\)," you are to describe a process that...
Study smarter with the SolutionInn App