%I #14 Nov 21 2016 09:27:11
%S 2,5,8,19,36,73,144,293,576,1153,2304,4613,9216,18437,36870,73741,
%T 147468,294949,589896,1179799,2359596,4719199,9438390,18876787,
%U 37753544,75507097,151014174,302028365,604056726,1208113469,2416226932,4832453865,9664907704,19329815417,38659630806
%N a(1)=2, a(n+1)=a(n)+p, where p is the largest prime <a(n) if a(n) is odd or the smallest prime >a(n) if a(n) is even.
%H Robert Israel, <a href="/A277263/b277263.txt">Table of n, a(n) for n = 1..2000</a>
%e a(2)=2+3=5 since 2 is even and 3 the smallest prime >2.
%e a(3)=5+3=8 since 5 is odd and 3 is the largest prime <5.
%e a(4)=8+11 since 8 is even and 11 is the smallest prime >8. Etc.
%p A[1]:= 2:
%p for k from 1 to 50 do
%p A[2*k]:= A[2*k-1] + nextprime(A[2*k-1]);
%p A[2*k+1]:= A[2*k] + prevprime(A[2*k]);
%p od:
%p seq(A[i],i=1..100); # _Robert Israel_, Nov 20 2016
%t NestList[# + If[OddQ@ #, NextPrime[#, -1], NextPrime@ #] &, 2, 34] (* ~~~ *)
%o (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
%Y Cf. A277224.
%K nonn
%O 1,1
%A _David James Sycamore_, Oct 07 2016
%E More terms from _Michel Marcus_, Oct 07 2016
|