OFFSET
0,1
COMMENTS
a(0) = 2. For n > 0, let f(m) = minimal distance from m to closest prime (excluding m itself). The a(n) = min { m : f(m) = 2n }.
f(m) is tabulated in A051700. - R. J. Mathar, Nov 18 2007
FORMULA
a(n) = A051652(2*n). - Sean A. Irvine, Oct 01 2021
MAPLE
A051700 := proc(m) if m <= 2 then op(m+1, [2, 1, 1]) ; else min(nextprime(m)-m, m-prevprime(m)) ; fi ; end: A051728 := proc(n) local m ; if n = 0 then RETURN(2); else for m from 0 do if A051700(m) = 2 * n then RETURN(m) ; fi ; od: fi ; end: seq(A051728(n), n=0..20) ; # R. J. Mathar, Nov 18 2007
MATHEMATICA
a[n_] := Module[{m}, If[n == 0, Return[2], For[m = 0, True, m++, If[Min[NextPrime[m]-m, m-NextPrime[m, -1]] == 2*n, Return[m]]]]]; Table[Print[an = a[n]]; an, {n, 0, 33}] (* Jean-François Alcover, Feb 11 2014, after R. J. Mathar *)
Join[{2}, With[{t=Table[{n, Min[n-NextPrime[n, -1], NextPrime[n]-n]}, {n, 0, 1358000}]}, Table[SelectFirst[t, #[[2]]==2k&], {k, 33}]][[All, 1]]] (* Harvey P. Dale, Aug 13 2019 *)
CROSSREFS
KEYWORD
nonn,easy,nice
AUTHOR
EXTENSIONS
More terms from James A. Sellers, Dec 07 1999
More terms from Amiram Eldar, Aug 28 2021
STATUS
approved