login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A051701 Closest prime to n-th prime p that is different from p (break ties by taking the smaller prime). 5
3, 2, 3, 5, 13, 11, 19, 17, 19, 31, 29, 41, 43, 41, 43, 47, 61, 59, 71, 73, 71, 83, 79, 83, 101, 103, 101, 109, 107, 109, 131, 127, 139, 137, 151, 149, 151, 167, 163, 167, 181, 179, 193, 191, 199, 197, 199, 227, 229, 227, 229, 241, 239, 257, 251, 257, 271, 269 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

A227878 gives the terms occurring twice. - Reinhard Zumkeller, Oct 25 2013

LINKS

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

EXAMPLE

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

MATHEMATICA

a[n_] := (p = Prime[n]; np = NextPrime[p]; pp = NextPrime[p, -1]; If[np-p < p-pp, np, pp]); Table[a[n], {n, 1, 58}] (* Jean-François Alcover, Oct 20 2011 *)

cp[{a_, b_, c_}]:=If[c-b<b-a, c, a]; Join[{3}, cp/@Partition[Prime[Range[ 60]], 3, 1]] (* Harvey P. Dale, Oct 08 2012 *)

PROG

(Haskell)

a051701 n = a051701_list !! (n-1)

a051701_list = f 2 $ 1 : a000040_list where

   f d (q:ps@(p:p':_)) = (if d <= d' then q else p') : f d' ps

     where d' = p' - p

-- Reinhard Zumkeller, Oct 25 2013

CROSSREFS

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

Sequence in context: A211940 A230664 A175717 * A225696 A134945 A256185

Adjacent sequences:  A051698 A051699 A051700 * A051702 A051703 A051704

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 October 15 01:40 EDT 2019. Contains 328025 sequences. (Running on oeis4.)