[go: up one dir, main page]

login
Search: a113425 -id:a113425
     Sort: relevance | references | number | modified | created      Format: long | short | data
Distance from n^2 to closest prime.
+10
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
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
KEYWORD
nonn
AUTHOR
Labos Elemer, Mar 23 2001
STATUS
approved
Greatest prime closest to n^2.
+10
4
2, 5, 11, 17, 23, 37, 47, 67, 83, 101, 127, 149, 167, 197, 227, 257, 293, 331, 359, 401, 443, 487, 523, 577, 631, 677, 727, 787, 839, 907, 967, 1021, 1091, 1153, 1223, 1297, 1367, 1447, 1523, 1601, 1693, 1759, 1847, 1933, 2027, 2113, 2207, 2309, 2399, 2503
OFFSET
1,1
COMMENTS
A060272(n) = abs(A000290(n) - a(n));
A113425(n) <= a(n).
LINKS
MATHEMATICA
f[n_]:=Module[{n2=n^2, np1, np2}, np1=NextPrime[n2, -1]; np2=NextPrime[n2]; If[(n2-np1)<(np2-n2), np1, np2]]
Table[f[i], {i, 50}]
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Oct 31 2005
STATUS
approved

Search completed in 0.004 seconds