login
A109619
Smallest prime p such that 2n+p is the square of a prime, or 0 if no such prime exists.
2
2, 5, 3, 17, 0, 13, 11, 0, 7, 5, 3, 97, 23, 0, 19, 17, 0, 13, 11, 0, 7, 5, 3, 73, 71, 0, 67, 113, 0, 61, 59, 0, 103, 53, 0, 97, 47, 0, 43, 41, 0, 37, 83, 0, 31, 29, 0, 73, 23, 0, 19, 17, 0, 13, 11, 0, 7, 5, 3, 241, 47, 0, 43, 41, 0, 37, 227, 0, 31, 29, 0, 0, 23, 0, 19, 17
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
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
Sequence in context: A282575 A002565 A063703 * A248576 A087228 A285743
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