sjkaliski/numbers.js — pull request #17 by timrwood (2012-12-12 00:30:10+00:00)
Title: Faster prime calculation with Math.sqrt

When checking prime numbers, rather than evaluating all integers up to the target number, you can stop evaluating at the square root of the target number.

Any pair of factors for a number must contain a factor equal or less than the square root of the number.

Here is the performance difference with this change. http://jsperf.com/prime-with-sqrt 1024 times faster for calculating 999983!