Describes the trial division algorithm as given an integer


You will be implementing an application to determine which of a set of integers are prime numbers using the "trial division" method. This can be a time-consuming effort for large numbers, so you will connect to a server (possibly a high-end server, but in our case just another process on your own machine) and the server will use multiple threads, one for each check of a candidate prime number.

Describes the trial division algorithm as follows: "Given an integer n, the integer to be factored, trial division consists of systematically testing whether n is divisible by any smaller number. Clearly, it is only worthwhile to test candidate factors less than n, and in order from two upwards because an arbitrary n is more likely to be divisible by two than by three, and so on.

Furthermore, the trial factors need go no further than because, if n is divisible by some number p, then n = p × q and if q were smaller than p, n would have earlier been detected as being divisible by q or a prime factor of q."

There are many steps to add efficiency to the algorithm, but the basic trial division algorithm will be sufficient for this assignment. In other words, to check if a number is a prime, loop from 2 to the square root of the number, and for each loop divide the number by the index.

If it divides evenly (i.e., if n % i == 0), then n is not a prime, for any i from 2 to the square root of n.

Attachment:- Assign.zip

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Describes the trial division algorithm as given an integer
Reference No:- TGS01141170

Now Priced at $60 (50% Discount)

Recommended (98%)

Rated (4.3/5)