login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A051702 Distance from n-th prime to closest prime. 19
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 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,3

LINKS

T. D. Noe, Table of n, a(n) for n = 1..10000

EXAMPLE

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

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 *)

PROG

(PARI) a(n, p=prime(n))=min(p-precprime(p-1), nextprime(p+1)-p) \\ Charles R Greathouse IV, Feb 06 2017

CROSSREFS

Related sequences: A023186-A023188, A046929-A046931, A051650, A051652, A051697-A051702, A051728-A051730.

A046929(n+1) + 1.

Sequence in context: A003642 A100007 A104369 * A073130 A238267 A143526

Adjacent sequences:  A051699 A051700 A051701 * A051703 A051704 A051705

KEYWORD

nonn,easy,nice

AUTHOR

N. J. A. Sloane

EXTENSIONS

More terms from James A. Sellers

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 28 04:30 EST 2022. Contains 350654 sequences. (Running on oeis4.)