\"Sieve of Eratosthenes\" ( method of finding primenumbers) a) Create a primitiv
ID: 3609585 • Letter: #
Question
"Sieve of Eratosthenes" ( method of finding primenumbers) a) Create a primitive type boolean array with allelements initialized to true. Array elements with primeindices will remain true. All other array elements willeventually be set to false. b) Starting with array index 2, determine whether agiven element is true. If so, loop through the remainder ofthe array and set to false every element whose index is a multipleof the index for the element with value true. Then continuethe process with the next element with value true. For arrayindex 2, all elements beyond element 2 in the array that haveindices which are multiples of 2 (indices 4, 6, 8, 10,etc.) will be set to false; for array index 3, all elementsbeyond element 3 in the array that have indices which are multiplesof 3 (indices 6, 9, 12, 15, etc.) will be set to false; and soon. When this process completes, the array elements that are stilltrue indicate that the index is a prime number. These indicescan be displayed. Write an application that uses an array of1000 elements to determine and display the prime numbers between 2and 999. Ignore array elements 0 and 1. "Sieve of Eratosthenes" ( method of finding primenumbers) a) Create a primitive type boolean array with allelements initialized to true. Array elements with primeindices will remain true. All other array elements willeventually be set to false. b) Starting with array index 2, determine whether agiven element is true. If so, loop through the remainder ofthe array and set to false every element whose index is a multipleof the index for the element with value true. Then continuethe process with the next element with value true. For arrayindex 2, all elements beyond element 2 in the array that haveindices which are multiples of 2 (indices 4, 6, 8, 10,etc.) will be set to false; for array index 3, all elementsbeyond element 3 in the array that have indices which are multiplesof 3 (indices 6, 9, 12, 15, etc.) will be set to false; and soon. When this process completes, the array elements that are stilltrue indicate that the index is a prime number. These indicescan be displayed. Write an application that uses an array of1000 elements to determine and display the prime numbers between 2and 999. Ignore array elements 0 and 1.Explanation / Answer
please rate - thanks import java.io.*; public class sieveofE {public static void main(String[] args) {int i,j,max=1000; boolean sieve[]=new boolean[max]; for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.