@mmk92: Props on realizing that you can improve execution time.
A small misconception though: As counter intuitive as it may seem, halving the number of steps is not a
huge improvement over the original one. As a matter of facts, by canceling the even numbers, you're only taking out a small fraction of the necessary steps (since determining the primality of an even number is a
very fast computation. It's only one step!).
Scientists have a way of measuring the
complexity of an algorithm. And they do this by approximations, it's not an exact science.
According to this theory, multiplying (or dividing) this complexity by a constant factor, is always a void operation. For instance, if the complexity of execution of your code is a variable called O(X), then by definition it's also equivalent to O(X/2).
I did
write a blog post a few months ago about testing very large numbers for primality. You should take a look.