[go: up one dir, main page]

login
Search: a113426 -id:a113426
     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
Smallest prime closest to n^2.
+10
3
2, 3, 7, 17, 23, 37, 47, 61, 79, 101, 127, 139, 167, 197, 223, 257, 293, 317, 359, 401, 439, 487, 523, 577, 619, 677, 727, 787, 839, 907, 967, 1021, 1087, 1153, 1223, 1297, 1367, 1447, 1523, 1601, 1669, 1759, 1847, 1933, 2027, 2113, 2207, 2309, 2399, 2503
OFFSET
1,1
COMMENTS
A060272(n) = abs(A000290(n) - a(n));
a(n) <= A113426(n).
LINKS
MAPLE
f:= proc(n) local k, d;
for k from 1 do
for d in [-1, 1] do
if isprime(n^2 + k*d) then return n^2 + k*d fi
od od
end proc:
map(f, [$1..100]); # Robert Israel, Mar 10 2017
MATHEMATICA
sp[n_]:=Module[{n2=n^2 , npu, npd}, npu=NextPrime[n2]; npd=NextPrime[n2, -1]; If[n2-npd<=npu-n2, npd, npu]]; sp/@Range[50] (* Harvey P. Dale, Feb 05 2011 *)
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Oct 31 2005
STATUS
approved
Greatest prime closest to n^3.
+10
1
2, 7, 29, 67, 127, 211, 347, 509, 727, 997, 1327, 1733, 2203, 2741, 3373, 4099, 4909, 5827, 6857, 7993, 9257, 10651, 12163, 13829, 15629, 17579, 19681, 21961, 24391, 26993, 29789, 32771, 35933, 39301, 42863, 46663, 50651, 54869, 59333, 63997, 68917, 74093, 79493, 85193, 91127, 97327, 103813, 110597, 117643, 125003
OFFSET
1,1
LINKS
EXAMPLE
29 is the greatest prime closest to 3^3 = 27.
MATHEMATICA
f3[n_]:=Module[{n3=n^3, np1, np2}, np1=NextPrime[n3, -1]; np2=NextPrime[n3]; If[(n3-np1)<(np2-n3), np1, np2]];
Table[f3[i], {i, 50}]
PROG
(PARI) a(n) = {if(n == 1, return(1)); my(n3 = n^3, gp = nextprime(n^3), lp = precprime(n^3)); if(n3 - lp < gp - n3, return(lp) , return(gp) ) } \\ David A. Corneth, May 25 2021
CROSSREFS
Cf. A113426.
KEYWORD
nonn
STATUS
approved

Search completed in 0.007 seconds