Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A051699
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A051699 Distance from n to closest prime. +0
17
2, 1, 0, 0, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 1, 0, 1, 0, 1 (list; graph; listen)
OFFSET

0,1

LINKS

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

Eric Weisstein's World of Mathematics, Prime Distance

FORMULA

Conjecture: S(n) = sum(k=1, n, a(k) ) is asymptotic to C*n*log(n) with C=0.29...... - Benoit Cloitre (benoit7848c(AT)orange.fr), Aug 11 2002

Comment from Giorgio Balzarotti (greenblue(AT)tiscali.it), Sep 18 2005: by means of the Prime Number Theorem is possible to derive the following inequality : c1*n*log(n) < S(n)< c2*n*log(n), where log is the natural logarithm and c1 = 1/4 and c2 = 3/8 (for n > 130). For a more accurate estimation of the values for c1 and c2, it necessary to know the number of twin primes with respect to the total number of primes.

EXAMPLE

Closest primes to 0,1,2,3,4 are 2,2,2,3,3.

MAPLE

A051699 := proc(n) if isprime(n) then 0; elif n<= 2 then 2-n ; else min(nextprime(n)-n, n-prevprime(n)) ; end if ; end proc; [From R. J. Mathar (mathar(AT)strw.leidenuniv.nl), Nov 01 2009]

MATHEMATICA

FormatSequence[ Table[Min[Abs[n-If[n<2, 2, Prime[{#, #+1}&[PrimePi[n]]]]]], {n, 0, 101}], 51699, 0, Name->"Distance to closest prime." ]

PROGRAM

(PARI) a(n)=if(n<1, 2*(n==0), vecmin(vector(n, k, abs(n-prime(k)))))

(PARI) a(n)=if(n<1, 2*(n==0), min(nextprime(n)-n, n-precprime(n)))

CROSSREFS

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

Sequence in context: A140727 A140728 A130068 this_sequence A007920 A127587 A082926

Adjacent sequences: A051696 A051697 A051698 this_sequence A051700 A051701 A051702

KEYWORD

nonn,easy,nice,new

AUTHOR

N. J. A. Sloane (njas(AT)research.att.com).

EXTENSIONS

More terms from James A. Sellers (sellersj(AT)math.psu.edu)

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified November 23 17:09 EST 2009. Contains 167438 sequences.


AT&T Labs Research