cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A051728 Smallest number at distance 2n from nearest prime.

This page as a plain text file.
%I A051728 #22 Jul 02 2025 16:01:58
%S A051728 2,0,23,53,409,293,211,1341,1343,2179,3967,15705,16033,19635,31425,
%T A051728 24281,31429,31431,31433,155959,38501,58831,203713,268343,206699,
%U A051728 370311,370313,370315,370317,1349591,1357261,1272749,1357265,1357267,2010801,2010803,2010805,2010807
%N A051728 Smallest number at distance 2n from nearest prime.
%C A051728 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 }.
%C A051728 f(m) is tabulated in A051700. - _R. J. Mathar_, Nov 18 2007
%F A051728 a(n) = A051652(2*n). - _Sean A. Irvine_, Oct 01 2021
%p A051728 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
%t A051728 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_ *)
%t A051728 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 *)
%Y A051728 Related sequences: A023186-A023188, A046929-A046931, A051650, A051652, A051697-A051702, A051728-A051730.
%Y A051728 Cf. A132470.
%K A051728 nonn,easy,nice
%O A051728 0,1
%A A051728 _N. J. A. Sloane_
%E A051728 More terms from _James Sellers_, Dec 07 1999
%E A051728 More terms from _Amiram Eldar_, Aug 28 2021