login
Least prime p such that 2n can be written as the sum or absolute difference of p and the next prime, or -1 if no such prime exists.
2

%I #32 Jul 06 2023 16:57:28

%S -1,3,7,23,3,139,5,113,1831,7,887,1129,11,2477,2971,13,5591,1327,17,

%T 30593,19333,19,15683,81463,28229,31907,23,35617,82073,44293,29,34061,

%U 89689,162143,31,173359,31397,404597,212701,37,542603,265621,41,155921,544279,43,927869,1100977

%N Least prime p such that 2n can be written as the sum or absolute difference of p and the next prime, or -1 if no such prime exists.

%C In recent years, a number of problems have been investigated that concern representing integers as the signed sum of consecutive prime numbers. See, for example, A327467 and the Rivera link.

%C A000230, which concerns prime gaps, can be considered a more historic such sequence. Here we look at a minor generalization of A000230 in the spirit of signed sums.

%C When a(n) <> -1, a(n) together with the next prime generate a satisfactory example for proving A362465(2n) = 2.

%H Carlos Rivera, <a href="https://www.primepuzzles.net/conjectures/conj_021.htm">Conjecture 21. Rivera's conjecture</a>, The Prime Puzzles and Problems Connection.

%F If 2n is in A001043 then a(n) = prime(k), where k is the position of 2n in A001043, otherwise for n > 0, a(n) = A000230(n).

%F a(n) = -1 if and only if A362465(2n) <> 2.

%o (Python)

%o from sympy import sieve as prime

%o def A363544(n):

%o if n == 0: return -1

%o k = 2

%o while (prime[k] + prime[k+1]) < 2*n and (prime[k] + prime[k+1]) // 2 != n: k += 1

%o if (prime[k] + prime[k+1]) // 2 == n: return prime[k]

%o k = 2

%o while (prime[k+1] - prime[k]) // 2 != n: k += 1

%o return prime[k]

%o print([A363544(n) for n in range(0,50)])

%Y Cf. A000040, A000230, A001043, A001223, A327467, A359199, A362465.

%K sign

%O 0,2

%A _Karl-Heinz Hofmann_ and _Peter Munn_, Jun 09 2023