login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A172022
a(n) = prime(n) + (-1)^n.
1
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,2
COMMENTS
1 together with A014687.
FORMULA
a(n+1) = A014687(n).
EXAMPLE
a(1) = prime(1) + (-1)^1 = 2 - 1 = 1.
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 *)
PROG
(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
(Magma) [NthPrime(n) + (-1)^n: n in [1..60]]; // Vincenzo Librandi, Feb 13 2015
CROSSREFS
Sequence in context: A046558 A180854 A014687 * A152967 A376433 A301705
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
Entries checked by D. S. McNeil, Dec 01 2010
STATUS
approved