OFFSET
1,2
COMMENTS
The sequence is the union of {1} and a permutation of even positive integers. The corresponding partial sums + 1 are 3, 5, 11, 19, 23, 37, 47, 59, 79, 97, 113, 137, 163, 191, 223. See A084758. - Zak Seidov, Feb 10 2015
Or, first differences of A084758. - Zak Seidov, Feb 10 2015
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = MIN{k>0 such that 2 + k + SUM[i=1..n-1]a(i) is prime and k <> a(i)}.
EXAMPLE
a(1) = 1 because 1+2 = 3 is prime.
a(2) = 2 because 1+2+2 = 5 is prime.
a(3) = 6 because 1+2+6+2 = 11 is prime.
a(4) = 8 because 1+2+6+8+2 = 19 is prime.
a(5) = 4 because 1+2+6+8+4+2 = 23 is prime.
MAPLE
M:= 300: # to get all entries before the first entry > N
a[1]:= 1:
s:= 3:
R:= {seq(2*i, i=1..M/2)}:
found:= true:
for n from 2 while found do
found:= false;
for r in R do
if isprime(s+r) then
a[n]:= r;
s:= s + r;
R:= R minus {r};
found:= true;
break
fi
od:
od:
seq(a[i], i=1..n-2); # Robert Israel, Feb 10 2015
MATHEMATICA
f[s_] := Append[s, k = 1; p = 2 + Plus @@ s; While[MemberQ[s, k] || ! PrimeQ[p + k], k++ ]; k]; Nest[f, {}, 67] (* Robert G. Wilson v, Aug 31 2006 *)
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jonathan Vos Post, Aug 30 2006
EXTENSIONS
More terms from Robert G. Wilson v, Aug 31 2006
STATUS
approved