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!)
A060272 Distance from n^2 to closest prime. 5
1, 1, 2, 1, 2, 1, 2, 3, 2, 1, 6, 5, 2, 1, 2, 1, 4, 7, 2, 1, 2, 3, 6, 1, 6, 1, 2, 3, 2, 7, 6, 3, 2, 3, 2, 1, 2, 3, 2, 1, 12, 5, 2, 3, 2, 3, 2, 5, 2, 3, 8, 3, 6, 1, 2, 1, 2, 3, 10, 7, 2, 3, 2, 3, 4, 1, 4, 3, 2, 3, 2, 5, 4, 1, 2, 3, 2, 5, 6, 3, 2, 5, 6, 1, 4, 3, 4, 3, 2, 1, 6, 3, 2, 1, 4, 5, 4, 3, 2, 7, 8, 5, 2 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,3
LINKS
FORMULA
a(n) = abs(A000290(n) - A113425(n)) = abs(A000290(n) - A113426(n)). - Reinhard Zumkeller, Oct 31 2005
EXAMPLE
n=1: n^2=1 has next prime 2, so a(1)=1;
n=11: n^2=121 is between primes {113,127} and closer to 127, thus a(11)=6.
MAPLE
seq((s-> min(nextprime(s)-s, `if`(s>2, s-prevprime(s), [][])))(n^2), n=1..256); # edited by Alois P. Heinz, Jul 16 2017
MATHEMATICA
Table[Function[k, Min[k - #, NextPrime@ # - k] &@ If[n == 1, 0, Prime@ PrimePi@ k]][n^2], {n, 103}] (* Michael De Vlieger, Jul 15 2017 *)
Min[#-NextPrime[#, -1], NextPrime[#]-#]&/@(Range[110]^2) (* Harvey P. Dale, Jun 26 2021 *)
PROG
(PARI) a(n) = if (n==1, nextprime(n^2) - n^2, min(n^2 - precprime(n^2), nextprime(n^2) - n^2)); \\ Michel Marcus, Jul 16 2017
CROSSREFS
Sequence in context: A219254 A072504 A072499 * A209315 A352218 A174713
KEYWORD
nonn
AUTHOR
Labos Elemer, Mar 23 2001
STATUS
approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 8 19:26 EDT 2024. Contains 372341 sequences. (Running on oeis4.)