OFFSET
1,1
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..2000
EXAMPLE
The six closest primes to 1327 are 1321 (difference = 6), 1319 (difference = 8), 1307 (different = 20), 1303 (difference = 24), 1301 (difference =26) and 1297 (difference = 30). 1321, 1319, 1307, 1303, 1301 and 1297 are all smaller than 1327, so 1327 is in the list.
MATHEMATICA
NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; ps = {0, 0, 0, 0, 0, 0, 0, 1}; Do[ps = Drop[ps, 1]; ps = Append[ps, NextPrim[ ps[[ -1]]]]; If[ ps[[ -1]] - ps[[ -2]] > ps[[ -2]] - ps[[1]], Print[ ps[[ -2]]]], {n, 1, 13872}]
Select[Prime[Range[15000]], #-NextPrime[#, -6]<NextPrime[#]-#&] (* Harvey P. Dale, Nov 21 2019 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Neil Fernandez, Oct 10 2002
EXTENSIONS
Edited by Robert G. Wilson v, Oct 11 2002
STATUS
approved