When I made my prime generator, I did it a different way...

If you take your range of numbers... lets say 20, starting with one. go like so...

Well, we know 1 is a prime. so skip that.
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

(things that we've called primes are in bold, composites are in italics)

now, we will eliminate every multiple of 2.

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

ok, now we see that three is the next prime (because its the next not elimanated number).
So, lets kill multiples of 3.

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

mmk, Most of those we already eliminated - but so what.

5 is next

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

ok, well that didn't do much.

Well, now that its 11's turn and that is more than half of the range of numbers (20/2==10) there is no reason to check the rest.

Any non-eliminated number is prime.

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

hmmm... those italics didn't show up very well... oh well.