cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A172989 Smallest k such that the two numbers n^2 +- k are primes.

Original entry on oeis.org

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

Views

Author

Keywords

Examples

			2^2 +- 1 are both prime, 3^2 +- 2 are both prime, 4^2 +- 3 are both prime, 5^2 +- 6 are both prime, ...
		

Crossrefs

Cf. A060272 (at least one prime), A082467 (supersequence).

Programs

  • 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
  • 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}]
  • PARI
    a(n) = my(k=1); while(!isprime(n^2+k) || !isprime(n^2-k), k++); k; \\ Michel Marcus, May 20 2018
    

Formula

a(n) = A082467(n^2). - Ivan N. Ianakiev, Jul 28 2019