login
a(1)=1, a(n+1) = a(n) + p, where p is the largest prime < a(n) if a(n) is even and the smallest prime > a(n) if a(n) is odd.
1

%I #17 Oct 28 2016 17:53:25

%S 1,3,8,15,32,63,130,257,520,1029,2060,4113,8240,16477,32958,65915,

%T 131836,263633,527280,1054553,2109130,4218257,8436528,16873045,

%U 33746094,67492171,134984390,269968777,539937558,1079875091,2159750220,4319500381,8639000780,17278001533,34556003072,69112006095

%N a(1)=1, a(n+1) = a(n) + p, where p is the largest prime < a(n) if a(n) is even and the smallest prime > a(n) if a(n) is odd.

%C Probably a(n) ~ k * 2^n where k is about 1.005712.... - _Charles R Greathouse IV_, Oct 07 2016, corrected Oct 21 2016

%e a(2)=a(1)+2=1+2=3, since a(1)=1 is odd and 2 is the smallest prime >1.

%e a(3)=3+5=8, since a(2)=3 is odd and 5 is the smallest prime >3.

%e Then a(4)=8+7=15 since a(3)=8 is even and 7 is the largest prime <8. Etc.

%t NestList[# + NextPrime[#, -1 + 2 Boole[OddQ@ #]] &, 1, 35] (* _Michael De Vlieger_, Oct 07 2016 *)

%o (PARI) lista(nn)=print1(a = 1, ", "); for (n=2, nn, if (a % 2, a += nextprime(a+1), a += precprime(a-1)); print1(a, ", ");); \\ _Michel Marcus_, Oct 07 2016

%Y Cf. A277263.

%K nonn

%O 1,2

%A _David James Sycamore_, Oct 06 2016