The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes (below 10 million or so).