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.

A051650 Lonely numbers: distance to closest prime sets a new record.

Original entry on oeis.org

0, 23, 53, 120, 211, 1340, 1341, 1342, 1343, 1344, 2179, 3967, 15704, 15705, 16033, 19634, 19635, 24281, 31428, 31429, 31430, 31431, 31432, 31433, 38501, 58831, 155964, 203713, 206699, 370310, 370311, 370312, 370313, 370314, 370315, 370316
Offset: 0

Views

Author

Keywords

Examples

			23 is 4 units away from the closest prime (not including itself), so 23 is in the sequence.
		

Crossrefs

Distances are in A051730.

Programs

  • Mathematica
    d[0] = 2; d[k_] := Min[k - NextPrime[k, -1], NextPrime[k] - k]; a[0] = 0; a[n_] := a[n] = (k = a[n-1] + 1; record = d[a[n-1]]; While[d[k] <= record, k++]; k); Table[a[n], {n, 0, 35}] (* Jean-François Alcover, Jan 16 2012 *)
    dcp[n_]:=Min[n-NextPrime[n,-1],NextPrime[n]-n]; DeleteDuplicates[Table[{n,dcp[n]},{n,0,375000}],GreaterEqual[#1[[2]],#2[[2]]]&][[;;,1]] (* Harvey P. Dale, Feb 23 2023 *)
  • PARI
    print1(0);w=2;p=2;q=3;forprime(r=5,1e9,if(p+w+ww,w=t;print1(", "q));p=q;q=r) \\ Charles R Greathouse IV, Jan 16 2012

Extensions

More terms from James Sellers, Dec 23 1999 and from Jud McCranie, Jun 16 2000