%I #24 Feb 14 2018 09:59:26
%S 0,2,1,4,3,5,6,11,7,9,8,13,10,15,12,16,14,23,17,20,18,25,19,21,22,31,
%T 24,30,26,29,27,35,28,34,32,38,33,48,36,37,39,41,40,44,42,53,43,50,45,
%U 46,47,55,49,52,51,57,54,66,56,60,58,63,59,62,61,78,64,84
%N Lexicographically first permutation of the nonnegative integers such that Sum_{k=n..2n} a(k) is a prime number, with a(1)=0.
%C Previous name: a(1)=0; for n>1, a(n) is the least number not yet used having the property that a(n) added with the next n terms is a prime number.
%C The corresponding primes are 2, 7, 13, 29, 41, 59, 79, 101, 127, 157, 191, 223, 263, 307, 347, 397, 443, 499, 557, 613, 673, 739, 809, 883, 953, 1033, 1103, 1187, 1277, 1367, 1459, 1553, 1657, 1777, ...
%C This is a permutation of the integers. - _Michel Marcus_, Jun 21 2015
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e a(1)= 0 plus the next single term 2 is 2 (a prime);
%e a(2)= 2 plus the next two terms (1,4) is 7 (a prime);
%e a(3)= 1 plus the next three terms (4,3,5) is 13 (a prime);
%e a(4)= 4 plus the next four terms (3,5,6,11) is 29 (a prime);
%e a(5)= 3 plus the next five terms (5,6,11,7,9) is 41 (a prime).
%p nn:=100:T:=array(1..nn):T[1]:=0:T[2]:=2:kk:=2:lst:={0,2}:
%p for n from 2 to nn do:
%p ii:=0:
%p for k from 1 to 1000 while(ii=0)do:
%p if {k} intersect lst = {}
%p then
%p ii:=1:lst:=lst union {k}:kk:=kk+1:T[kk]:=k:
%p else
%p fi:
%p od:
%p jj:=0:n0:=nops(lst):s:=sum('T[i]', 'i'=n..n0):
%p for p from 1 to 100 while(jj=0) do:
%p z:=s+p:
%p if type(z,prime)=true and {p} intersect lst={}
%p then
%p jj:=1:lst:=lst union {p}:kk:=kk+1:T[kk]:=p:
%p else
%p fi:
%p od:
%p od:
%p print(T):
%Y Cf. A000040, A247665, A259018.
%K nonn
%O 1,2
%A _Michel Lagneau_, Jun 16 2015
%E Name edited by _Jon E. Schoenfield_, Sep 12 2017