Question: Write a program that obtains the execution time for finding all the prime numbers less than 8,000,000, 10,000,000, 12,000,000, 14,000,000, 16,000,000, and 18,000,000 using the
Write a program that obtains the execution time for finding all the prime numbers less than 8,000,000, 10,000,000, 12,000,000, 14,000,000, 16,000,000, and 18,000,000 using the algorithms in Listings 22.5?22.7. Your program should print a table like this:
Listing 22.5PrimeNumbers.java
![import java.util.Scanner; 3 public class PrimeNumbers { public static void main(String[] args)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a73ac38a4d_812636a73ac283cc.jpg)
Listing 22.6EfficientPrimeNumbers.java


Listing 22.7SieveOfEratosthenes.java

10000000 8000000 12000000 14000000 16000000 18000000 Listing 22.5 Listing 22.6 Listing 22.7 import java.util.Scanner; 3 public class PrimeNumbers { public static void main(String[] args) { Scanner input = new Scanner(System. in); System.out.print("Find all prime numbers = n, enter n: "); int n - input.nextInt (); 10 11 final int NUMBER_PER_LINE = 10; // Display 10 per line int count = 0; // Count the number of prime numbers int number = 2; // A number to be tested for primeness 12 13 System.out.println("The prime numbers are:"); 14 15 16 // Repeatedly find prime numbers while (number
Step by Step Solution
3.34 Rating (175 Votes )
There are 3 Steps involved in it
Program Plan Create a class Exercise2214 which contains method to print prime number calculation tim... View full answer
Get step-by-step solutions from verified subject matter experts
