Skip to content Skip to sidebar Skip to footer

Prime Numbers Generator Explanation?

I was searching for an algorithm to generate prime numbers. I found the following one done by Robert William Hanks. It is very efficient and better than the other algorithms but I

Solution 1:

Starting with nTrue values in an array, with i enumerated from 3 to sqrt(n) by the step of 2, if the ith entry in the array is still True, set to False all entries from i^2 to the end of the array by the step of 2*i (these all will be multiples of i).

All odd True entries above 1 that are left in the array in the end, are prime.

All thus found numbers, and 2, are all the prime numbers that exist below n.

Post a Comment for "Prime Numbers Generator Explanation?"