Improving Your Solution
If we find that testNumber is not prime, then we don’t have to continue looping
Also, we don’t need to test all the numbers from 2,...,testNumber-1. It is sufficient to test the numbers 2,...,sqrt(testNumber)
See PrimeNumbers2
Previous slide
Back to first slide
View graphic version