OFFSET
1,6
COMMENTS
It appears that any prime (and also any odd number > 1, see A260870) can be written as the sum of two positive integers such that the sum of their squares is prime. For an even number > 2 this is obviously not possible since k and 2n-k have the same parity and therefore the sum of their squares is even.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(n) = A260870((prime(n)-1)/2) for n > 1. - Robert Israel, Oct 10 2024, corrected by M. F. Hasler, Oct 10 2024
MAPLE
f:= proc(n) local p, k;
p:= ithprime(n);
for k from 1 to p do if isprime(k^2 + (p-k)^2) then return k fi od;
0
end proc:
map(f, [$1..100]); # Robert Israel, Oct 10 2024
PROG
(PARI) A260869(n)=for(k=1, (n=prime(n))\2, isprime(k^2+(n-k)^2)&&return(k))
(Python)
from sympy import prime, isprime
def A260869(n):
p = prime(n)
return next((k for k in range(1, (p>>1)+1) if isprime(k**2+(p-k)**2)), 0) # Chai Wah Wu, Oct 14 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Aug 09 2015
EXTENSIONS
Corrected by Robert Israel, Oct 10 2024
STATUS
approved