Originally Posted byCrazyNorman

That's known as a Seive of Erosthenes, and is probably the fastest method of generating prime numbers.

Also, you do not need to check every number less than number/2, it's less than sqrt(number), because after you check the square root, any other factor above it must have a matching factor below.

e.g. 36.

Instead of testing up to 18, you only need to test up to 6, because although something like 9 is a higher factor, it has to be paired with a lower number, namely 4.