OFFSET
1,1
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
The eight closest primes to 15683 are 15679 (difference = 4), 15671 (difference = 12), 15667 (difference = 16), 15661 (difference = 22), 15649 (difference = 34), 15647 (difference = 36), 15643 (difference = 40) and 15641 (difference = 42). These are all smaller than 15683 so 15683 is in the list.
MATHEMATICA
NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; ps = {0, 0, 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, 58393}]
Select[Partition[Prime[Range[55000]], 10, 1], #[[9]]-#[[1]]<#[[10]]-#[[9]]&][[All, 9]] (* Harvey P. Dale, Feb 20 2022 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Neil Fernandez, Oct 10 2002
EXTENSIONS
Edited and extended by Robert G. Wilson v, Oct 11 2002
STATUS
approved