Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #34 Mar 02 2019 03:02:56
%S 3,2,3,5,5,11,7,11,11,17,11,17,13,23,17,23,17,31,19,41,23,41,23,47,29,
%T 47,37,59,29,59,31,59,43,67,37,67,37,67,43,73,41,83,43,83,47,101,47,
%U 97,53,97,59,97,53,103,61,109,67,127,59,131
%N a(n) = least prime p_k such that n = p_k - p_{k-1} + ... + (-1)^{k-j}p_j for some 1 <= j <= k, with p_k the k-th prime.
%C a(n) is obviously at least n. In March 2012, Zhi-Wei Sun conjectured that a(n) always exists and does not exceed 2.2*n for n > 1; he even thought that 2.2*n might be replaced by 2*n + 2.5*sqrt(n) for n > 1.
%C IFF n=p, a(n)=1.
%C For odd n's, lim_{n->inf.} a(n)/n = 1; for even n's, lim_{n->inf.} a(n)/n = 2.
%H Robert G. Wilson v, <a href="/A182003/b182003.txt">Table of n, a(n) for n = 1..10000</a> (first 5000 terms from Zhi-Wei Sun)
%H Zhi-Wei Sun, <a href="http://arxiv.org/abs/1202.6589">On functions taking only prime values</a>, preprint, arxiv:1202.6589 [math.NT], 2012-2013.
%H Zhi-Wei Sun, <a href="http://listserv.nodak.edu/cgi-bin/wa.exe?A2=NMBRTHRY;a32182f.1203">A representation problem involving consecutive primes</a>, a message to Number Theory List, Mar 31 2012.
%H Zhi-Wei Sun, <a href="http://listserv.nodak.edu/cgi-bin/wa.exe?A2=NMBRTHRY;95333354.1203">An amazing recurrence for primes</a>, a message to Number Theory List, Mar 31 2012.
%e We have a(4) = 5 since 4 = 5 - 3 + 2 and 3 - 2 < 4.
%t s[0_]:=0; s[n_]:=s[n]=Prime[n]-s[n-1]; Do[Do[If[s[j]-(-1)^(j-i)*s[i]==n, Print[n," ",Prime[j]]; Goto[aa]], {j, 1, PrimePi[3n]}, {i, 0, j-1}]; Print[n]; Label[aa]; Continue, {n, 1, 5000}]
%t f[n_] := Block[{j = PrimePi[n]}, While[ !MemberQ[ Accumulate@ Table[(-1)^(j - i) Prime[i], {i, j, 1, -1}], n], j++]; Prime[j]]; Array[f, 60] (* _Robert G. Wilson v_, Apr 06 2012 *)
%Y Cf. A000040, A181901, A210640, A210393, A210394, A210186, A210144, A208494, A208643, A207982.
%K nonn,nice
%O 1,1
%A _Zhi-Wei Sun_, Apr 05 2012