OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..2000
EXAMPLE
a(2)=2+3=5 since 2 is even and 3 the smallest prime >2.
a(3)=5+3=8 since 5 is odd and 3 is the largest prime <5.
a(4)=8+11 since 8 is even and 11 is the smallest prime >8. Etc.
MAPLE
A[1]:= 2:
for k from 1 to 50 do
A[2*k]:= A[2*k-1] + nextprime(A[2*k-1]);
A[2*k+1]:= A[2*k] + prevprime(A[2*k]);
od:
seq(A[i], i=1..100); # Robert Israel, Nov 20 2016
MATHEMATICA
NestList[# + If[OddQ@ #, NextPrime[#, -1], NextPrime@ #] &, 2, 34] (* ~~~ *)
PROG
(PARI) lista(nn) = {print1(a = 2, ", "); for (n=2, nn, if (a % 2, a += precprime(a-1), a += nextprime(a+1)); print1(a, ", "); ); } \\ Michel Marcus, Oct 07 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
David James Sycamore, Oct 07 2016
EXTENSIONS
More terms from Michel Marcus, Oct 07 2016
STATUS
approved