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.
%I A051730 #27 Jul 02 2025 16:01:58 %S A051730 2,4,6,7,12,13,14,15,16,17,18,20,21,22,24,25,26,30,31,32,33,34,35,36, %T A051730 40,42,43,44,48,49,50,51,52,53,54,55,56,57,62,63,64,65,66,67,68,69,70, %U A051730 71,72,73,74,75,76,77,96,98,99,100,101,102,103,104,105,106,107,108,109 %N A051730 Distance from A051650(n) to nearest prime. %H A051730 Amiram Eldar, <a href="/A051730/b051730.txt">Table of n, a(n) for n = 0..211</a> (calculated from the b-file at A051650) %e A051730 23 is 4 units away from the closest prime (not including itself), so 4 is in the sequence. %t A051730 (* b stands for A051650 *) d[0] = 2; d[k_] := Min[k - NextPrime[k, -1], NextPrime[k] - k]; b[0] = 0; b[n_] := b[n] = (k = b[n-1] + 1; record = d[b[n-1]]; While[d[k] <= record, k++]; k); a[n_] := a[n] = d[b[n]]; Table[ Print[ a[n]]; a[n], {n, 0, 66}] (* _Jean-François Alcover_, Jan 16 2012 *) %o A051730 (UBASIC) [10] C#=pack(3,5):R=2:N=4:print 2; [20] if N>member(C#,2) then C#=pack(member( C#,2)):C#=C#+nxtprm(member(C#,1)) [30] Prv=member(C#,1):Nxt=member(C#,2) [40] if Nxt=N then Nxt=nxtprm(N) [50] if (N-Prv)>=(Nxt-N) then P=Nxt-N else P=N-Prv [60] if P>R then print P;:R=P [70] N+=1 :goto 20 %o A051730 (PARI) print1(w=2);p=2;q=3;forprime(r=5,1e9,if(p+w+w<q,for(t=w+1,(q-p)\2,print1(", "t));w=(q-p)\2);t=min(q-p,r-q);if(t>w,w=t;print1(", "t));p=q;q=r) \\ _Charles R Greathouse IV_, Jan 16 2012 %Y A051730 Related sequences: A023186-A023188, A046929-A046931, A051650, A051652, A051697-A051702, A051728-A051730. %K A051730 nonn,easy,nice %O A051730 0,1 %A A051730 _N. J. A. Sloane_ %E A051730 More terms from _James Sellers_, Dec 23 1999 and from _Jud McCranie_, Jun 16 2000 %E A051730 Further terms from _Naohiro Nomoto_, Jun 21 2001