OFFSET
2
COMMENTS
There is no gap before 2, so we start with prime 3.
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 2..20000
Chris Caldwell, Prime Gaps [Broken link?]
Pe, J. L. Prime Gap Tug of War
C. Rivera, Puzzle 271: Prime gap tug of war.
FORMULA
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
KEYWORD
easy,sign
AUTHOR
Joseph L. Pe, Feb 02 2003
STATUS
approved