Ah, The Sieve of Eratosthenes. I wrote some on it a while back if anyone is interested:
http://www.cshrp.net/content.aspx?showID=612