Question: Write a class which tests runtime to find if n= 9223372036854775783 is a prime number. You will have to use long variables. The program should:

Write a class which tests runtime to find if n= 9223372036854775783 is a prime number. You will have to use long variables. The program should: - Create 10 threads to test if n is a prime number. This is achieved by distributing numbers to check divisability with each thread.( It is recomended you create an inner class which implements Runnable and tests whether n is divisable with numbers in a distinct area).

- Program should count the time it takes to do this operation, and print to console.

- Call a method which executes the above, only in one single thread. Count the time, and print to console.

When checking if the number is a prime number; first check if its an even number, find squareroot of number, then check if it is divisable by 3,5,7,9...squareroot . If one of these tests are true, then the number is an even number. If all tests are false, then it is a prime number.

UML- diagram: Write a class which tests runtime to find if n= 9223372036854775783 is

Console output example:

a prime number. You will have to use long variables. The program

Thank you!

d PrimeChecker O i pool Q i isPrime 0 i number Q i numberOfThreads O i startValues 0 i endValues m& PrimeCheckero c "So main(String l) ExecutorService boolean long int longl longD @ i runThreads) m i notPrime0 D a singlethreadedPrimeCheck0 void void void void boolean O PrimeTask D number O startValue 0 endValue long long long PrimeTasklong, long, long) void d PrimeChecker O i pool Q i isPrime 0 i number Q i numberOfThreads O i startValues 0 i endValues m& PrimeCheckero c "So main(String l) ExecutorService boolean long int longl longD @ i runThreads) m i notPrime0 D a singlethreadedPrimeCheck0 void void void void boolean O PrimeTask D number O startValue 0 endValue long long long PrimeTasklong, long, long) void

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!