[go: up one dir, main page]

login
Search: a060272 -id:a060272
     Sort: relevance | references | number | modified | created      Format: long | short | data
Smallest k such that the two numbers n^2 +- k are primes.
+10
9
1, 2, 3, 6, 5, 12, 3, 2, 3, 18, 5, 12, 3, 2, 15, 18, 7, 12, 21, 2, 63, 42, 55, 6, 15, 10, 27, 12, 19, 78, 15, 2, 93, 12, 5, 78, 15, 10, 21, 12, 23, 18, 57, 14, 27, 30, 7, 120, 117, 8, 15, 42, 37, 24, 27, 58, 93, 18, 7, 12, 75, 38, 3, 6, 7, 132, 27, 28, 69, 18, 5, 102, 27, 34, 75, 78, 5
OFFSET
2,2
LINKS
FORMULA
a(n) = A082467(n^2). - Ivan N. Ianakiev, Jul 28 2019
EXAMPLE
2^2 +- 1 are both prime, 3^2 +- 2 are both prime, 4^2 +- 3 are both prime, 5^2 +- 6 are both prime, ...
MATHEMATICA
f[n_]:=Block[{k}, If[OddQ[n], k=2, k=1]; While[ !PrimeQ[n-k]||!PrimeQ[n+k], k+=2]; k]; Table[f[n^2], {n, 2, 40}]
PROG
(PARI) a(n) = my(k=1); while(!isprime(n^2+k) || !isprime(n^2-k), k++); k; \\ Michel Marcus, May 20 2018
(Magma) sol:=[]; for m in [2..80] do for k in [1..200] do if IsPrime(m^2-k) and IsPrime(m^2+k) then sol[m-1]:=k; break; end if; end for; end for; sol; // Marius A. Burtea, Jul 28 2019
CROSSREFS
Cf. A060272 (at least one prime), A082467 (supersequence).
KEYWORD
nonn
AUTHOR
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
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
Least k such that the distance from k^2 to closest prime = n or zero if no k exists.
+10
1
1, 3, 8, 17, 12, 11, 18, 51, 200, 59, 238, 41, 276, 165, 104, 281, 214, 397, 348, 159, 650, 305, 778, 923, 2242, 1155, 1090, 911, 822, 1871, 1280, 1099, 1516, 3253, 2578, 5849, 3538, 693, 4010, 1937, 1284, 5095, 3212, 2011, 6268, 6331, 2160, 1943, 12470, 13443, 12836, 7405, 25428, 7115, 22596, 10873
OFFSET
1,2
COMMENTS
From Robert Israel, Jan 03 2017: (Start)
For n > 1, a(n) == n (mod 2) unless it is 0.
a(191) > 3*10^7 if it is not 0. (End)
LINKS
MAPLE
N:= 100: # for a(1)..a(N)
R[1]:= 1: count:= 1:
for k from 3 while count < N do
d:= min(nextprime(k^2)-k^2, k^2-prevprime(k^2));
if d <= N and not assigned(R[d]) then R[d]:= k; count:= count+1 fi
od:
seq(R[i], i=1..N); # Robert Israel, Jan 03 2017
PROG
(PARI) a(n)=if(n<0, 0, s=1; while(abs(n-min(abs(precprime(s^2)-s^2), abs(nextprime(s^2)-s^2)))>0, s++); s)
CROSSREFS
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Jan 26 2003
EXTENSIONS
More terms from Robert Israel, Jan 03 2017
STATUS
approved

Search completed in 0.005 seconds