OFFSET
1,1
COMMENTS
Many of the zeros can be understood: Let p = q^2-2*n, for q prime. q <= 3 only leads to positive p for n <= 4. For n > 4, q > 3 so q^2 mod 3 = 1, and if n = 2 mod 3 then p = 0 mod 3, so p is either 3 or a multiple of 3. Thus for n > 4 with n = 2 mod 3, a(n) = 3 or 0, and instances of 3 should become increasingly rare at large n. Not all zeros are of this form: when 2*n is a square, k^2, then (q^2-2*n)=(q-k)*(q+k) and p cannot be prime unless q-k=1. n=72=(12^2/2) is the first case for which a(n) = 0 and n is not congruent to 2 mod 3. Possibly all zeros fall into one of these two categories (all those for n<=10^5 do). - D. S. McNeil, Nov 24 2010
LINKS
Michel Marcus, Table of n, a(n) for n = 1..10000
EXAMPLE
For n=4, we find that 17+2*4=25=5^2 and no smaller prime than 17 works, so a(4)=17.
For n=5, the 2 mod 3 argument applies and a(5)=3 or 0; but 3+2*5=13 which is not a squared prime, so a(5)=0.
PROG
(PARI) b(n) = my(q); forprime(p=1, 200000, if (issquare(p+2*n, &q) && isprime(q), return(p))); \\ eventually to check a(n)
findp(n) = forprime(p=2, , if (issquare(p+2*n, &q) && isprime(q), return(p)));
a(n) = if (n <= 4, return(findp(n))); my(m = n % 3, k); if ((m == 2), if (issquare(2*n+3, &q) && isprime(q), return(3), return(0))); if (m == 0, if (issquare(2*n, &k), if (!isprime(1+k) || !isprime((1+k)^2-2*n), return(0)); ); ); findp(n); \\ Michel Marcus, Mar 06 2023
CROSSREFS
KEYWORD
nonn,look
AUTHOR
John W. Layman, Aug 01 2005
EXTENSIONS
Extended and correctness proved by D. S. McNeil, Nov 24 2010
More terms from Michel Marcus, Mar 06 2023
STATUS
approved