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.

A240131 Least k such that prime(n)^2 + k^2 is prime, or 0 if none.

Original entry on oeis.org

1, 2, 2, 2, 4, 2, 2, 6, 8, 4, 4, 2, 4, 8, 2, 10, 6, 10, 2, 6, 2, 4, 18, 4, 2, 10, 2, 10, 4, 18, 8, 16, 2, 10, 14, 4, 10, 2, 2, 10, 4, 6, 4, 2, 8, 16, 4, 18, 8, 4, 2, 10, 16, 14, 18, 8, 10, 6, 2, 4, 8, 2, 2, 4, 2, 2, 6, 20, 2, 14, 8, 10, 8, 2, 6, 12, 4, 18, 4, 6, 14, 4, 6, 12, 4, 28, 10, 12, 6, 2, 12, 14, 2, 6, 4, 2, 14, 14, 10, 6
Offset: 1

Views

Author

Jonathan Sondow, Apr 07 2014

Keywords

Comments

The main entry for this sequence is A240130.
k and p_n must be of opposite parity. Conjecture, there is always a k for any p_n. Tested for all primes < 15*10^10. - Robert G. Wilson v, Nov 04 2015
Least k > 0 for which prime(n)+i*k is a Gaussian prime. - Robert Israel, Nov 04 2015

Examples

			Prime(3) = 5 and 5^2 + 1^2 = 26 is not prime but 5^2 + 2^2 = 29 is prime, so a(3) = 2.
		

Crossrefs

Cf. A240130.

Programs

  • Maple
    f:= proc(p) local k; for k from 2 by 2 do if isprime(p^2 + k^2) then return k fi eod nd proc:
    f(2):= 1:
    map(f, select(isprime, [2,seq(2*i+1,i=1..10000)])); # Robert Israel, Nov 04 2015
  • Mathematica
    f[n_] := Block[{k = If[n == 1, 1, 2], p = Prime@ n}, While[ !PrimeQ[k^2 + p^2], k += 2]; k]; Array[f, 100]  (* Robert G. Wilson v, Nov 03 2015 *)
    lk[n_]:=Module[{k=2,n2=n^2},While[!PrimeQ[n2+k^2],k+=2];k]; Join[{1}, Table[ lk[x],{x,Prime[Range[2,100]]}]] (* Harvey P. Dale, Mar 22 2019 *)
  • PARI
    vector(100, n, p = prime(n); k = 1 - p%2; inc = 2; while (!isprime(q=p^2+k^2), k += inc); k; ) \\ Altug Alkan, Nov 04 2015

Formula

a(n)^2 = A240130(n) - prime(n)^2 if a(n) > 0.