The Sieve of Eratosthenes

See Sieve of Eratostheness (Wikipedia).