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”).

A079054
a(n) = -1 if the closest prime to prime(n) is prime(n-1); = 1 if the closest prime to prime(n) is prime(n+1); = 0 if prime(n-1) and prime(n+1) are equally close to prime(n).
6
-1, 0, -1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 0, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 0, 1, -1, 0, 1, -1, 1, -1, 1, -1, 0, 1, 1, -1, -1, 1, -1, 1, 0, 0, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 0, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1
OFFSET
2
COMMENTS
There is no gap before 2, so we start with prime 3.
LINKS
Chris Caldwell, Prime Gaps [Broken link?]
FORMULA
a(n) = min(1, max(-1, A001223(n-1) - A001223(n))). - Charles R Greathouse IV, Nov 16 2012
EXAMPLE
prime(1) = 2 is closer to prime(2) = 3 than prime(3) = 5, so a(2) = -1.
MAPLE
# From N. J. A. Sloane, Mar 13 2016
a:=[]; M:=120; for n from 2 to M-1 do
q:=ithprime(n); p:=prevprime(q); r:=nextprime(q);
if q-p < r-q then a:=[op(a), -1];
elif q-p=r-q then a:=[op(a), 0]; else a:=[op(a), 1]; fi;
od:
a;
MATHEMATICA
Table[-Sign[Prime[n-1] - 2*Prime[n] + Prime[n+1]], {n, 2, 100}]
PROG
(PARI) p=2; q=3; forprime(r=5, 97, print1(sign(2*q-r-p)", "); p=q; q=r) \\ Charles R Greathouse IV, Nov 16 2012
CROSSREFS
Cf. A092243 (cumulative sum, negated), A268343.
Sequence in context: A176412 A013596 A182394 * A131695 A324113 A105812
KEYWORD
easy,sign
AUTHOR
Joseph L. Pe, Feb 02 2003
STATUS
approved