I've withdrawn the -1 because now your answers adds something that is new; however, your code does not quite deserve a +1 yet... The approach - a windowed sieve - is indeed an excellent choice for this task but I doubt whether anyone
who does not know the algorithm yet can learn from your code how it works; nor is it a good example for others to follow. You might want to post it on Code Review, for advice on how to make it much slimmer, more efficient and - most importantly - more robust and more self-documenting/self-explanatory. And you can apply it all to PRIME1's big bad brother, PRINT. —
DarthGizka 8 secs ago