the sieve of Eratosthenes
I mentioned about selected method,but actually,it's the sieve of Eratosthenes,a most efficient way to list all small prime number,that is less or equal to 10,000,000,000.
Make a list of all the integers less than or equal to n (greater than one) and strike out the multiples of all primes less than or equal to the square root of n, then the numbers that are left are the primes.
For example, to find all the odd primes less than or equal to 100 we first list the odd numbers from 3 to 100 (why even list the evens?) The first number is 3 so it is the first odd prime--cross out all of its multiples. Now the first number left is 5, the second odd prime--cross out all of its multiples. Repeat with 7 and then since the first number left, 11, is larger than the square root of 100, all of the numbers left are primes.
ehh,after the basic instruction,I need to know some efficient implementation,since it's memory consuming in my idea(it's useless).