login
A219360
Starting from a(1)=1, for any n the sum of the next a(n) numbers is a prime. No repetition of numbers is allowed. At any step the minimum integer not yet used and not leading to a contradiction is chosen.
2
1, 2, 3, 4, 5, 8, 6, 10, 7, 12, 9, 11, 18, 16, 13, 22, 15, 14, 17, 23, 19, 20, 34, 21, 24, 25, 26, 33, 27, 40, 32, 42, 29, 28, 30, 46, 31, 37, 35, 39, 36, 38, 41, 43, 45, 44, 47, 48, 65, 49, 52, 50, 54, 51, 53, 66, 72, 55, 56, 57, 73, 68, 63, 58, 59, 61, 60, 82
OFFSET
1,2
COMMENTS
Permutation of natural numbers.
EXAMPLE
a(1)=1 -> next term is 2, prime.
a(2)=2 -> the sum of the next two terms 3 + 4 = 7, prime.
a(3)=3 -> 4 + 5 + 8 = 17, prime.
a(4)=4 -> 5 + 8 + 6 + 10 = 29, prime.
a(5)=5 -> 8 + 6 + 10 + 7 + 12 = 43, prime.
a(6)=8 but we also have a(7)=6 that must be covered before a(6).
Therefore the sequence became: 1, 2, 3, 4, 5, 8, 6, 10, 7, 12, 9, 11, 18, ... with 10 + 7 + 12 + 9 + 11 + 18 = 67, prime.
Then coming back to a(6)=8: 1, 2, 3, 4, 5, 8, 6, 10, 7, 12, 9, 11, 18, 16, ... with 6 + 10 + 7 + 12 + 9 + 11 + 18 + 16 = 89.
It could happen that two or more sums must be satisfied at the same step. If it is not possible we must change the most recent entries. For example, the sequence up to a(30) is: 1, 2, 3, 4, 5, 8, 6, 10, 7, 12, 9, 11, 18, 16, 13, 22, 14, 15, 17, 23, 19, 20, 34, 21, 24, 25, 26, 33, 27, 40.
Now a(13)=18 and a(17)=14 must be satisfied in a(31) but 16 + 13 + 22 + 14 + 15 + 17 + 23 + 19 + 20 + 34 + 21 + 24 + 25 + 26 + 33 + 27 + 40 = 389 (odd) and 15 + 17 + 23 + 19 + 20 + 34 + 21 + 24 + 25 + 26 + 33 + 27 + 40 = 324 (even) and no integer a(31) can satisfy the system 389 + a(31) = p1 and 324 + a(31) = p2, with p1 and p2 both prime. Therefore we must change a(17)=14 into a new minimum value, in this case a(17)=15, and restart the sequence from that point.
PROG
(PARI)
PTest(t, u)={for(i=1, #u, if(!isprime(t-u[i]), return(0))); 1}
XTest(u)={forprime(p=2, #u, if(#Set(u%p) >= p, return(0))); 1}
seq(n)={
my(v=vector(n), f=vector(2*n), M=Map(), p=1, t=0);
for(k=1, #v, my(S, X);
while(f[p], p++);
if(mapisdefined(M, k, &S), mapdelete(M, k), S=[]);
for(q=p, oo, if(!f[q] && PTest(t+q, S),
X = if(mapisdefined(M, q+k, &X), concat(X, [t+q]), [t+q]);
if(XTest(X), mapput(M, q+k, X); t += q; f[q]=1; v[k]=q; break);
)));
v
} \\ Andrew Howroyd, Jun 05 2021
CROSSREFS
Sequence in context: A355429 A192179 A118462 * A275877 A245819 A207802
KEYWORD
nonn
AUTHOR
Paolo P. Lava, Nov 19 2012
STATUS
approved