login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Least k > 0 such that k^2 + (prime(n)-k)^2 is a prime, or 0 if no such k exists.
3

%I #22 Oct 14 2024 23:57:39

%S 1,1,1,1,1,3,1,2,3,2,5,1,1,3,2,4,2,3,1,6,3,4,4,2,2,3,3,5,7,3,1,1,2,2,

%T 2,1,1,3,10,3,2,1,3,3,10,7,1,3,7,7,4,9,1,1,1,8,2,1,2,1,8,4,1,3,5,5,8,

%U 6,5,2,3,2,10,4,5,3,5,1,1,2,10,1,1,4,12,4,2,2,6,5,1,2,7,1,12,4,2

%N Least k > 0 such that k^2 + (prime(n)-k)^2 is a prime, or 0 if no such k exists.

%C 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.

%H Robert Israel, <a href="/A260869/b260869.txt">Table of n, a(n) for n = 1..10000</a>

%e a(n) = A260870((prime(n)-1)/2) for n > 1. - _Robert Israel_, Oct 10 2024, corrected by _M. F. Hasler_, Oct 10 2024

%p f:= proc(n) local p,k;

%p p:= ithprime(n);

%p for k from 1 to p do if isprime(k^2 + (p-k)^2) then return k fi od;

%p 0

%p end proc:

%p map(f, [$1..100]); # _Robert Israel_, Oct 10 2024

%o (PARI) A260869(n)=for(k=1,(n=prime(n))\2,isprime(k^2+(n-k)^2)&&return(k))

%o (Python)

%o from sympy import prime, isprime

%o def A260869(n):

%o p = prime(n)

%o 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

%Y Cf. A260870.

%K nonn

%O 1,6

%A _M. F. Hasler_, Aug 09 2015

%E Corrected by _Robert Israel_, Oct 10 2024