I'm writing a script that will check whether or not a number is prime and I'm having some issues on how to do this.
If I take a number, lets say 100, and I want to check and see if it's prime I could do this:
-Divide it by all numbers 2..99 to see whether or not 100 is divisible by them. If not, it passes (it's prime.)
-Check whether it's divisible by 2. If so, it fails (composite.) If its not di
If I choose to check whether it's divisible by 2, then, if it's not, move onto 3... and THEN if its not divisible by 3, I could really bring the size of the pool of numbers down to ~1/3rd of its original size...
However, when do I stop? At the 1/4 size? 1/8 size?
Optimally, I'd like to do as few operations as possible.
The code that produces the array is as follows: