Question: All responses must be orignal or will not be accepted as a valid answer. Primality Test Program Write a program to test for primality of
All responses must be orignal or will not be accepted as a valid answer.
Primality Test Program
Write a program to test for primality of any number N (that is, to test if N is a prime number). Start by writing an algorithm (a set of precise mathematical steps that can be written into a program) to test for primality. For full credit, run the program and use it to test for primality on several numbers. See what the largest number your program can handle is before you find it too slow to yield a result in a reasonable time (if it takes longer than 10 minutes to execute, you are done).
Use your own imagination. Remember that if the number N is even, it cannot be a prime number. You can write your program to simply try if it is a multiple of any numbers smaller than N. Also you can design your program to store all prime numbers less than N that your program has found, then take advantage of the fact that a number only needs to be tested to see if it is a multiple of those prime numbers smaller than N/2. If it is not, then it must be a prime number itself.
You may use any language you prefer, but it is recommended you use C# or C++ because these are the languages supported by DeVry in the programming courses you have taken.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
