login
A051730
Distance from A051650(n) to nearest prime.
18
2, 4, 6, 7, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 24, 25, 26, 30, 31, 32, 33, 34, 35, 36, 40, 42, 43, 44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 96, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109
OFFSET
0,1
LINKS
Amiram Eldar, Table of n, a(n) for n = 0..211 (calculated from the b-file at A051650)
EXAMPLE
23 is 4 units away from the closest prime (not including itself), so 4 is in the sequence.
MATHEMATICA
(* 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 *)
PROG
(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
(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
CROSSREFS
KEYWORD
nonn,easy,nice
EXTENSIONS
More terms from James A. Sellers, Dec 23 1999 and from Jud McCranie, Jun 16 2000
Further terms from Naohiro Nomoto, Jun 21 2001
STATUS
approved