login
a(n) = (-1)^n + (n-th prime of the form 3k-+1).
1

%I #15 Feb 10 2019 00:42:08

%S 1,6,6,12,12,18,18,24,28,32,36,42,42,48,52,60,60,68,70,74,78,84,88,98,

%T 100,104,106,110,112,128,130,138,138,150,150,158,162,168,172,180,180,

%U 192,192,198,198,212,222,228,228,234,238,242,250,258,262,270,270,278

%N a(n) = (-1)^n + (n-th prime of the form 3k-+1).

%H Michael De Vlieger, <a href="/A176569/b176569.txt">Table of n, a(n) for n = 1..10001</a>

%F a(n) = (-1)^n + A045344(n). - _Michel Marcus_, Feb 07 2019

%p A045344 := proc(n) if n = 1 then 2; else ithprime(n+1) ; end if; end proc:

%p A176569 := proc(n) (-1)^n+A045344(n) ; end proc:

%p seq(A176569(n),n=1..120) ; # _R. J. Mathar_, Apr 27 2010

%t Total /@ Nest[Append[#1, Block[{p = NextPrime@ #1[[-1, -1]]}, While[Mod[p, 3] == 0, p = NextPrime@ p]; {(-1)^#2, p}]] & @@ {#, Length@ # + 1} &, {{-1, 2}}, 57] (* _Michael De Vlieger_, Feb 09 2019 *)

%o (PARI) a045344(n) = if(n<2, 2, prime(n+1));

%o a(n) = (-1)^n + a045344(n); \\ _Michel Marcus_, Feb 07 2019

%Y Cf. A045344.

%K nonn

%O 1,2

%A _Juri-Stepan Gerasimov_, Apr 20 2010

%E Corrected (double-5 replaced by double-6, 146 removed) by _R. J. Mathar_, Apr 27 2010