OFFSET
1,2
EXAMPLE
The 4th term is 3 and the 4th composite is 9.
3 - 9 is negative, so instead add 9 to 3 to get 12, which becomes the 5th term because 12 is not among the earlier terms of the sequence.
MATHEMATICA
composite[n_] := FixedPoint[ n + PrimePi[#] + 1 & , n + PrimePi[n] + 1]; lst = {1}; Do[b = Last[lst]; p = composite[Length[lst]]; If[b > p && ! MemberQ[lst, b - p], AppendTo[lst, b - p], If[ ! MemberQ[lst, b + p], AppendTo[lst, b + p], AppendTo[lst, 0]]], {100}]; lst (* Jean-François Alcover, Nov 15 2013, after A006509 and Robert G. Wilson v *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Oct 13 2005
EXTENSIONS
More terms from Klaus Brockhaus, Oct 17 2005
STATUS
approved