OFFSET
1,2
COMMENTS
The sequence is started with a(1)=1 and always extended with the smallest integer not yet used that doesn't lead to a contradiction.
The sequence is a permutation of the natural numbers.
LINKS
EXAMPLE
The blocks of nonprime integers are indicated here by parentheses; the successive block-sizes are 1, 2, 3, 4, 6,... which reproduces the sequence itself: P = (1),2,3,(4,6),5,7,(8,9,10),11,(12,14,15,16),13,17,(18,20,21,22,24,25),19,23.
MATHEMATICA
a[1]=1; a[n_]:=a[n]=Block[{k=1}, While[MemberQ[s=Array[a, n-1], k]||(g=Length/@Select[SplitBy[Join[s, {k}], !PrimeQ@#&], !PrimeQ@First@#&]; g!=s[[;; Length@g]]), If[!PrimeQ@k&&FreeQ[s, k], Break[], k++]]; k]; Array[a, 93] (* Giorgos Kalogeropoulos, May 12 2022 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Eric Angelini, Aug 02 2016
STATUS
approved