!lm12
!rm76
Even Faster Primes.............................Charles Putney
[  Charlie is a long-time friend and subscriber in Ireland  ]

Bob, I wanted to answer your challenge in the Ocotber 1981 AAL for some time, but this is the first chance I had.  You sifted out the primes in 690 milliseconds, and challenged readers to beat your time.  I did it!

I increased the speed by using a faster algorithm, and by using some self-modifying code in the loops.  I know self-modifying code is dangerous, and a NO-NO, but it amounts to about 50 milliseconds improvement.

The algorithm changes are an even greater factor.  The main ideas for the sieve are:
!lm17

1.  Only check odd numbers
2.  Get next increment from the prime array.
    This means you only knock out primes.
3.  Start knocking out at P^2.  That is,
    if prime found is 3, start at 9.
4.  Increment the knock-out index by 2*P.
    This avoids knocking out even numbers.
5.  Stop at the square-root of the maximum number.
!lm12

Your algorithm did all the above except 3 and 4.

With these routines, a generation takes 330 milliseconds.  This is over twice as fast as yours!

You could still shave a little time off by optimizing the square routine, and even including it inline since it is only called from one place.

I'll grant you that this is not the same algorithm, but the goal is to find primes fast.  I know throw down the glove for the next challenger!
