OFFSET
1,3
COMMENTS
There cannot be a solution for an odd number of terms on the l.h.s. because all terms are odd but the r.h.s. is even.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..300
FORMULA
a(n) = [x^5] Product_{k=3..2*n+1} (x^prime(k) + 1/x^prime(k)). - Ilya Gutkovskiy, Jan 31 2024
EXAMPLE
a(1) = 1 because prime(2) - prime(3) = -2.
a(2) = 0 because prime(2) +- prime(3) +- prime(4) +- prime(5) is different from -2 for any choice of the signs.
a(3) = 2 counts the 2 solutions prime(2) - prime(3) + prime(4) - prime(5) - prime(6) + prime(7) = -2 and prime(2) - prime(3) - prime(4) + prime(5) + prime(6) - prime(7) = -2.
MAPLE
s:= proc(n) option remember;
`if`(n<3, 0, ithprime(n)+s(n-1))
end:
b:= proc(n, i) option remember; `if`(n>s(i), 0, `if`(i=2, 1,
b(abs(n-ithprime(i)), i-1)+b(n+ithprime(i), i-1)))
end:
a:= n-> b(5, 2*n+1):
seq(a(n), n=1..30); # Alois P. Heinz, Aug 08 2015
MATHEMATICA
s[n_] := s[n] = If[n<3, 0, Prime[n]+s[n-1]]; b[n_, i_] := b[n, i] = If[n > s[i], 0, If[i == 2, 1, b[Abs[n-Prime[i]], i-1] + b[n+Prime[i], i-1]]]; a[n_] := b[5, 2*n+1]; Table[a[n], {n, 1, 30}] (* Jean-François Alcover, Nov 11 2015, after Alois P. Heinz *)
PROG
(PARI) A261059(n, rhs=-2, firstprime=2)={rhs-=prime(firstprime); my(p=vector(2*n-2+bittest(rhs, 0), i, prime(i+firstprime))); sum(i=1, 2^#p-1, sum(j=1, #p, (-1)^bittest(i, j-1)*p[j])==rhs)} \\ For illustrative purpose; too slow for n >> 10.
(PARI) a(n, s=-2-3, p=2)=if(n<=s, if(s==p, n==s, a(abs(n-p), s-p, precprime(p-1))+a(n+p, s-p, precprime(p-1))), if(s<=0, a(abs(s), sum(i=p+1, p+2*n-1, prime(i)), prime(p+n*2-1))))
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Aug 08 2015
EXTENSIONS
a(15)-a(29) from Alois P. Heinz, Aug 08 2015
STATUS
approved