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.

A284211 a(n) is the least positive integer such that n^2 + a(n)^2 and n^2 + (a(n) + 2)^2 are primes.

Original entry on oeis.org

2, 1, 8, 9, 2, 29, 8, 3, 14, 1, 4, 23, 8, 9, 2, 29, 8, 5, 14, 1, 44, 13, 18, 59, 4, 9, 20, 13, 4, 11, 4, 3, 188, 9, 16, 149, 28, 13, 44, 1, 44, 23, 8, 19, 14, 19, 8, 35, 4, 17, 14, 3, 10, 59, 4, 9, 50, 3, 24, 29, 24, 43, 38, 9, 2, 89, 18, 5, 194, 17, 14, 5
Offset: 1

Views

Author

Lars-Erik Svahn, Mar 23 2017

Keywords

Comments

z = n + i*a(n) and z' = n + i*(a(n) + 2) are two Gaussian primes such that |z - z'| = 2, corresponding to twin primes.

Examples

			a(1)=2: 1^2 + 1^2 = 2 is a prime but 1 + (1 + 2)^2 = 10 is not, while 1^2 + 2^2 = 5 and 1^2 + (2+2)^2 = 17 are both primes.
		

Crossrefs

Cf. A069003.

Programs

  • Maple
    f:= proc(n) local k,pp,p;
        pp:= false;
        for k from (n+1) mod 2 by 2 do
          p:= isprime(n^2 + k^2);
          if p and pp then return k-2 fi;
          pp:= p;
        od;
    end proc:
    map(f, [$1..100]); # Robert Israel, Mar 30 2017
  • Mathematica
    a[n_] := Block[{k = Mod[n, 2] + 1}, While[! PrimeQ[n^2 + k^2] || ! PrimeQ[n^2 + (k + 2)^2], k += 2]; k]; Array[a, 72] (* Giovanni Resta, Mar 23 2017 *)
    lpi[n_]:=Module[{k=1},While[!AllTrue[n^2+{k^2,(k+2)^2},PrimeQ],k++];k]; Array[lpi,80] (* Harvey P. Dale, Aug 15 2024 *)
  • PARI
    a(n) = my(k=n%2+1); while (!(isprime(n^2+k^2) && isprime(n^2+(k+2)^2)), k+=2); k  \\ Michel Marcus, Mar 25 2017