Question: a.Create a primitive type booleanarray with all elements initialized to true. Array elements with prime indices will remain true. All other array elements will eventually

a.Create a primitive type booleanarray 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 istrue. If so, look 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.Then continue the process with the next element with value true. For array index 2, all elementsbeyond element 2 in the array that have indices which are multiples of 2 (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 trueindicate that the index is a prime number. Write a Java programthat uses an array of 10,000 elements to compute the sieve of prime numbers, and then display the ten prime numbers closest to (but less than) 10,000.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!