A259019 Lexicographically first permutation of the nonnegative integers such that Sum_{k=n..2n} a(k) is a prime number, with a(1)=0.
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, 24, 30, 26, 29, 27, 35, 28, 34, 32, 38, 33, 48, 36, 37, 39, 41, 40, 44, 42, 53, 43, 50, 45, 46, 47, 55, 49, 52, 51, 57, 54, 66, 56, 60, 58, 63, 59, 62, 61, 78, 64, 84
Offset: 1
Keywords
Examples
a(1)= 0 plus the next single term 2 is 2 (a prime); a(2)= 2 plus the next two terms (1,4) is 7 (a prime); a(3)= 1 plus the next three terms (4,3,5) is 13 (a prime); a(4)= 4 plus the next four terms (3,5,6,11) is 29 (a prime); a(5)= 3 plus the next five terms (5,6,11,7,9) is 41 (a prime).
Programs
-
Maple
nn:=100:T:=array(1..nn):T[1]:=0:T[2]:=2:kk:=2:lst:={0,2}: for n from 2 to nn do: ii:=0: for k from 1 to 1000 while(ii=0)do: if {k} intersect lst = {} then ii:=1:lst:=lst union {k}:kk:=kk+1:T[kk]:=k: else fi: od: jj:=0:n0:=nops(lst):s:=sum('T[i]', 'i'=n..n0): for p from 1 to 100 while(jj=0) do: z:=s+p: if type(z,prime)=true and {p} intersect lst={} then jj:=1:lst:=lst union {p}:kk:=kk+1:T[kk]:=p: else fi: od: od: print(T):
Extensions
Name edited by Jon E. Schoenfield, Sep 12 2017
Comments