A263978 Least prime p such that n^2 + p^2 is prime, or 0 if none.
2, 3, 2, 5, 2, 5, 2, 3, 0, 3, 0, 7, 2, 11, 2, 5, 2, 5, 0, 3, 0, 5, 0, 5, 0, 5, 2, 5, 0, 11, 0, 3, 2, 5, 2, 5, 2, 3, 0, 3, 0, 5, 0, 19, 2, 5, 2, 13, 0, 7, 0, 3, 0, 11, 0, 11, 2, 3, 0, 13, 0, 3, 0, 11, 2, 29, 2, 5, 0, 3, 0, 5, 2, 5, 0, 5, 0, 7, 0, 7, 0, 3, 0, 11, 2, 11, 2, 3, 0, 11, 0, 7, 0, 5, 2, 5, 2, 3, 0, 3
Offset: 1
Keywords
Examples
a(1) = 2 since 1^2 + 2^2 = 5 is prime. a(2) = 3 since 2^2 + 2^2 = 8 is not prime but 2^2 + 3^2 = 13 is prime. a(9) = 0 since 9^2 + 2^2 = 85 is not prime.
Programs
-
Mathematica
f[n_] := If[OddQ[n] && ! PrimeQ[n^2 + 4], 0, Block[{p = 2}, While[! PrimeQ[n^2 + p^2] && p < 1500, p = NextPrime@p]; p]]; Array[f, 100]
Comments