login
A172989
Smallest k such that the two numbers n^2 +- k are primes.
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).
Sequence in context: A106379 A232929 A001634 * A095113 A345179 A367584
KEYWORD
nonn
AUTHOR
STATUS
approved