2. Testing for Prime Numbers
You can test if a number P is a prime by checking to make sure P % n (n is an integer) is not zero for lots of values 1 < n < P. Write a program to input a number (or generate a number randomly) and test it against k random values. Pick a bunch of known composite numbers and see how accurately your program rejects them. See if the results improve for larger values of k. Try k = 10, 100, 1000 and 10,000. You can easily try the program against large composite numbers by including:
i. Even numbers
ii. Numbers whose final digit is a 5
iii. Numbers where the sum of the digits is divisible by 3.
iv. Number constructed as the product of two positive integers.
v. Randomly generated numbers X that are then adjusted as follows:
X = X - X%K <-- X will now be divisible by K.
Students succeed in their courses by connecting and communicating with an expert until they receive help on their questions

Consult our trusted tutors.