Implement the Sieve of Eratosthenes and use it to find all primenumbers less than or equal to one million. Use the result toprove Goldbach’s Conjecture for all even integers between four andone million, inclusive.

Implement a method with the following declaration:

public static void sieve(int[] array);

This function takes an integer array as its argument. The arrayshould be initialized to the values 1 through 1000000. Thefunction modifies the array so that only the prime numbers remain;all other values are zeroed out.

This function must be written to accept an integer array of anysize. You must should output for all primes numbers between 1 and1000000, but when I test your function it may be on an array of adifferent size.

Implement a method with the following declaration:

public static void goldbach(int[] array);

This function takes the same argument as the previous methodand displays each even integer between 4 and 1000000 with twoprime numbers that add to it.

The goal here is to provide an efficient implementation. Thismeans no multiplication, divisioni, or modulus when determining ifa number is prime. It also means that the second method must findtwo primes efficiently.

Output for your program: All prime numbers between 1 and 1000000and all even numbers between 4 and 1000000 and the two primenumbers that sum up to it.

 

"Get yourself this Paper or a similar one at an unbeatable discount!"

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon
"FIRST15"

Order Now