Visit https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes to learn more about the Sieve of Eratosthenes. The algorithm as implemented in Fig. 23.6

Question:

Visit https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes to learn more about the Sieve of Eratosthenes. The algorithm as implemented in Fig. 23.6 is inefficient, because it keeps eliminating multiples of primes even after the array already represents all primes up to the maximum entered by the user. The algorithm is complete once it eliminates the multiples of all primes that are less than or equal to the square root of the maximum value. Make the following modifications to Fig. 23.6:
a) Update the algorithm to eliminate multiples of primes that are less than or equal to the square root of the maximum value.
b) Modify the code that updates the Progress Bar and percentage Label so that they indicate the progress of the Sieve of Eratosthenes algorithm, rather than the progress of checking whether each number in the range is prime.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Visual C# How to Program

ISBN: 978-0134601540

6th edition

Authors: Paul J. Deitel, Harvey Deitel

Question Posted: