in reply to What am I missing?

I'm writing a Sieve of Eratosthenes.

Detail the algorithm in words. Also, Use strict warnings and diagnostics or die :D

Replies are listed 'Best First'.
Re^2: What am I missing?
by neo_ (Novice) on Aug 11, 2009 at 02:17 UTC
    Alright, in words... The object is to get all prime numbers up to and including our input. First we take the lowest number, which in this case is 2. We need to eliminate all multiples of that number. In other words, create an array where the element values divided by 2 yields a remainder. At this point we have an array of nothing but stuff that is NOT divisible by 2. This is our new list, so we save it. Now we go up to 3 and repeat, saving our new array as we go. Ahhh, I see what's going on. The first element in each new array is greater than the element we are going to divide by. So it leaves 0 and a remainder. I need to use a floor or int function. Stay tuned...