Originally posted by buntine
for (int divisor = 2; divisor <= (n / 2); divisor++)
The condition here "divisor <= (n / 2)" can be altered to make it more efficient. You only need to check up to the square root of a number to see if it's prime. I know this doesn't really matter here since the numbers are so small, but I thought I should point it out anyway.
If you were to put the primes into an array as you find them, you could use those numbers to divide into the number being tested and you wouldn't have to bother running through 2, 3, 4, 5, 6, etc. every time.
The online version is here but the code on there is an absolute mess. I optimised it for speed so it's quite efficient but very hard to read. I just ran it on an Intel Celeron 466 and found all the primes up to 100,000 in 10 seconds.