Sieve of Erathostenes: removing consecutive items This question comes from https://stackoverflow.com/questions/13747873/why-does-this-prime-function-work, where somebody wrote a standard Sieve of Erathostenes algorithm --- with a bug.  However, the bug does not have any bad effect up to 1'000'000.  At this point, it would be interesting to know if we can find either a proof or a counter-example.
The question is: let L(n) denote the smallest prime factor of n.  Is there a prime number p and two integers b > a >= 2, with:


*

*L(ap) = L(bp) = p

*for any m such that ap < m < bp, L(m) < p.
The question and comments in question in prime numbers let us think that it might be false in general.  However I don't really see how to draw that conclusion so far.
EDIT: reformulated the problem (now close to Gerhard Paseman's formulation).
 A: Now that it looks like I am close to the intent of the question, I will point in the direction
of the answer.
I recommend checking out wheel sieving using an array of differences.  Note that if you
store differences between unmarked items, you save on space and add a little on time:
to get the next candidate add the current difference to the current candidate.
However, the sequence of differences is periodic, so you can save a lot of space and
manage time more effectively by just doing the work needed in one period.  Thus,
instead of looking at
2 2 2 2 2 ...
4 2 4 2 4 2 ...
6 4 2 4 2 4 6 2 6 4 ...
you instead work with 2 then with 4 2 then with 6 4 2 4 2 4 6 2 and so on.
I invite you to find the algorithm on your own.  Crandall and Pomerance
have an algorithmic prime number book which has pseudocode if you want
a reference.
The relevance of the above is that you are looking for an array of
differences where the first difference is q-1 and one of the differences
is 2q.  I am confident there is one where q is less than 97.  Possibly
q is 43.  When you find it, you will have (be able to construct) an example
as suggested above, and where the code
you mentioned will fail to remove a composite number.
Gerhard "Yes, Jacobsthal's Function Is Related" Paseman, 2012.12.08
A: This question is answered in the paper Paul Pritchard, Some negative results concerning prime number generators, Comm. ACM, vol. 27, no. 1, Jan. 1984, pp.53-57 .
The paper notes (at the start of p.54) that "Misra's conjecture can be given a familiar setting: it amounts to the claim that in no pass of Eratosthenes' sieve are successive remaining numbers removed."
The paper provides a mathematical disproof, and gives explicit composite numbers that constitute a counterexample. It uses the notion of wheels, as suggested in another comment.
A: Let $q$ be the next prime after $p$. The fact that primes exist between $p$ and $2p$ implies that $a-b$ must be less then $2$. This reduces the problem to finding a number $a$ and prime $p$ such that $ap+1, ap+2 \ldots ap+p-1$ all have prime factors less then $p$ while $a$ has only prime factor greater then $p$. This is not a complete solution, but is a step forward.
