1. Engineering
  2. Computer Science
  3. i need help with this assignment please make it simple...

Question: i need help with this assignment please make it simple...

Question details

I need help with this assignment (please make it simple)

This week, you will be writing 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 imagination. Remember that if the number N is even, it cannot be a prime number. You can write your program to simply see whether 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 also might consider that the fastest way to find out if N is a multiple of p is to divide N by p and see if the result is a whole number.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution