login
A356077
a(n) is the least prime p such that 2*n - p^2 is prime, or -1 if there is no such p.
2
-1, -1, 2, -1, -1, 3, 3, 3, -1, 3, 3, -1, 3, 3, 5, 3, -1, 5, 3, 3, 5, 5, 3, 5, 3, 3, 5, 3, -1, 7, 3, -1, 5, 3, 3, 5, -1, 3, 5, 3, 3, 5, 5, 3, 7, 3, -1, 5, 3, -1, 7, 5, 3, 5, 3, 3, 5, 3, 3, 7, 3, 11, 5, 5, -1, 5, 5, 3, 5, 3, -1, 11, 3, 3, 7, 5, -1, 5, 3, 3, 5, 5, 3, 11, -1, 3, 5, 3, -1, 7, 3, -1
OFFSET
1,3
COMMENTS
If n == 2 (mod 3), then a(n) is either -1, 3, or sqrt(n-3).
If 2*n is a square, then a(n) is either -1 or sqrt(2*n)-1 (in which case a(n) must be in A005384).
LINKS
EXAMPLE
a(7) = 3 because 2*7 - 3^2 = 5 is prime.
MAPLE
f:= proc(n) local p;
if n mod 3 = 2 then
if isprime(2*n-3^2) then return 3
elif issqr(2*n-3) and isprime(sqrt(2*n-3)) then return sqrt(2*n-3)
else return -1
fi fi;
p:= 1:
while p^2 < 2*n do
p:= nextprime(p);
if isprime(2*n-p^2) then return p fi
od;
-1
end proc:
map(f, [$1..100]);
CROSSREFS
Sequence in context: A279677 A262180 A308028 * A320902 A189913 A240807
KEYWORD
sign
AUTHOR
J. M. Bergot and Robert Israel, Jul 27 2022
STATUS
approved