login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A348639
Number of ways to express n in the form 1 +- 2 +- 3 ... +- n.
2
1, 0, 0, 1, 2, 0, 0, 6, 11, 0, 0, 57, 103, 0, 0, 615, 1131, 0, 0, 7209, 13467, 0, 0, 89261, 168515, 0, 0, 1147893, 2183943, 0, 0, 15181540, 29055149, 0, 0, 205171534, 394497990, 0, 0, 2820847321, 5444272739, 0, 0, 39329485312, 76142226498, 0, 0, 554756557011
OFFSET
1,5
COMMENTS
a(n) is the coefficient of x^(n*(n+3)/4-1) of Product_{k=2..n} (1+x^k). - Jianing Song, Nov 19 2021
LINKS
PROG
(C)
int solsN(int n, int k, int sum) { if (n == k) return sum == n; return solsN(n, k+1, sum + k + 1) + solsN(n, k+1, sum - k - 1); }
int getNumber(int n) { return solsN(n, 1, 1); }
(Python)
from functools import cache
@cache
def b(t, s, u): # target, sum, upto
if u == 1: return int(t == s + 1)
return b(t, s - u, u - 1) + b(t, s + u, u - 1)
def a(n): return b(n, 0, n)
print([a(n) for n in range(1, 49)]) # Michael S. Branicky, Oct 29 2021
(PARI) list(n) = my(poly=vector(n), v=vector(n)); poly[1]=1; for(k=2, n, poly[k]=poly[k-1]*(1+'x^k)); for(k=1, n, if(k%4==2||k%4==3, v[k]=0, v[k]=polcoeff(poly[k], k*(k+3)/4-1))); v \\ Jianing Song, Nov 19 2021
CROSSREFS
Sequence in context: A329290 A244133 A378495 * A244142 A161800 A246608
KEYWORD
nonn
AUTHOR
Daniel Cortild, Oct 26 2021
EXTENSIONS
a(30)-a(48) from Michael S. Branicky, Oct 29 2021
STATUS
approved