No need to keep searching for factors among lower prime numbers once you reach the square root (plus 1) of the number you are testing for primality. If you get there, you can safely quit the search: your number under testing for primality is a prime number. This, by the way, speeds up the program tremendously.
No need to keep searching for factors among lower prime numbers once you reach the square root (plus 1) of the number you are testing for primality. If you get there, you can safely quit the search: your number under testing for primality is a prime number. This, by the way, speeds up the program tremendously.