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.

A051702 Distance from n-th prime to closest prime.

Original entry on oeis.org

1, 1, 2, 2, 2, 2, 2, 2, 4, 2, 2, 4, 2, 2, 4, 6, 2, 2, 4, 2, 2, 4, 4, 6, 4, 2, 2, 2, 2, 4, 4, 4, 2, 2, 2, 2, 6, 4, 4, 6, 2, 2, 2, 2, 2, 2, 12, 4, 2, 2, 4, 2, 2, 6, 6, 6, 2, 2, 4, 2, 2, 10, 4, 2, 2, 4, 6, 6, 2, 2, 4, 6, 6, 6, 4, 4, 6, 4, 4, 8, 2, 2, 2, 2, 4, 4, 6, 4, 2, 2, 4, 8, 4, 4, 4, 4, 6, 2, 2, 6, 6, 6, 6, 2
Offset: 1

Views

Author

Keywords

Examples

			Closest primes to 2,3,5,7,11 are 3,2,3,5,13.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Min[(p = Prime[n]) - NextPrime[p, -1], NextPrime[p] - p]; Table[a[n], {n, 1, 104}] (* Jean-François Alcover, May 27 2013 *)
    Join[{1},Min[Differences[#]]&/@Partition[Prime[Range[110]],3,1]] (* Harvey P. Dale, Sep 23 2016 *)
  • PARI
    a(n,p=prime(n))=min(p-precprime(p-1),nextprime(p+1)-p) \\ Charles R Greathouse IV, Feb 06 2017

Extensions

More terms from James Sellers