A172022 a(n) = prime(n) + (-1)^n.
1, 4, 4, 8, 10, 14, 16, 20, 22, 30, 30, 38, 40, 44, 46, 54, 58, 62, 66, 72, 72, 80, 82, 90, 96, 102, 102, 108, 108, 114, 126, 132, 136, 140, 148, 152, 156, 164, 166, 174, 178, 182, 190, 194, 196, 200, 210, 224, 226, 230, 232, 240, 240, 252, 256, 264, 268, 272, 276
Offset: 1
Examples
a(1) = prime(1) + (-1)^1 = 2 - 1 = 1.
Programs
-
Magma
[NthPrime(n) + (-1)^n: n in [1..60]]; // Vincenzo Librandi, Feb 13 2015
-
Maple
A172022:=n->ithprime(n)+(-1)^n: seq(A172022(n), n=1..100); # Wesley Ivan Hurt, Jan 09 2017
-
Mathematica
upto=300;Total/@Partition[Riffle[Prime[Range[PrimePi[upto]]], {-1,1}], 2] (* Harvey P. Dale, May 12 2011 *) Table[Prime@ n + (-1)^n, {n, 59}] (* Michael De Vlieger, Jan 10 2017 *)
-
PARI
a(n)=prime(n)+(-1)^n \\ Charles R Greathouse IV, May 12 2011
-
PARI
k=1; forprime(p=2,300, print1(p+(k*=-1)", ")) \\ Charles R Greathouse IV, May 25 2011
Formula
a(n+1) = A014687(n).
Extensions
Entries checked by D. S. McNeil, Dec 01 2010
Comments