Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #40 Jan 30 2022 15:58:34
%S 1,0,1,0,1,0,1,1,4,5,9,15,26,45,77,137,243,434,774,1408,2554,4667,
%T 8627,15927,29559,54867,101688,189425,355315,668598,1264180,2395462,
%U 4506221,8507311,16084405,30545142,57898862,110199367,209957460,400430494,765333684
%N Number of solutions to +-2 +- 3 +- 5 +- 7 +- ... +- prime(n-1) = n.
%F a(n) = [x^n] Product_{k=1..n-1} (x^prime(k) + 1/x^prime(k)).
%t Table[SeriesCoefficient[Product[x^Prime[k] + 1/x^Prime[k], {k, n - 1}], {x, 0, n}], {n, 0, 40}] (* _Stefano Spezia_, Jan 30 2022 *)
%o (Python)
%o from sympy import sieve, primerange
%o from functools import cache
%o @cache
%o def b(n, i):
%o maxsum = 0 if i < 2 else sum(p for p in primerange(2, sieve[i-1]+1))
%o if n > maxsum: return 0
%o if i < 2: return 1
%o return b(n+sieve[i-1], i-1) + b(abs(n-sieve[i-1]), i-1)
%o def a(n): return b(n, n)
%o print([a(n) for n in range(41)]) # _Michael S. Branicky_, Jan 29 2022
%Y Cf. A000040, A022894, A058377, A063890, A113040, A261061, A350404.
%K nonn
%O 0,9
%A _Ilya Gutkovskiy_, Jan 29 2022