# How many solutions $\pm1\pm2\pm3…\pm n=0$

As the title said, I'm very interested how many variants to choose $n$ signs from all $2^n$ variants when expression lead to zero. I tried to get recurrent formula but nothing happened.

• It is 0 if $n$ gives remainder 1 or 2 modulo 4 (since such a sum would be odd). For $n$ congruent to 0 or 3 modulo $n$ it is the coefficient of $x^{n(n+1)/4}$ in the product $(1+x)(1+x^2)\dots (1+x^n)$. There is no known (or believed) general formula, but quite precise asymptotics. – Fedor Petrov Sep 26 '17 at 22:26
• Compute a few counts, enter a large one or two into OEIS, find oeis.org/A063865, and follow the references therein. [In gp, using Fedor Petrov's hint: for(n=0,40,if((n+1)%4<2,print([n,polcoeff(prod(m=1,n,1+x^m),(n^2+n)/4)]))) ] – Noam D. Elkies Sep 26 '17 at 23:09
• The function $(1+x)(1+x^{2})\cdots(1+x^{n})$ is a modular function, and as such there's a Rademacher-type formula for its coefficients (which is even given here). So there is a "general" formula. – Jeremy Rouse Sep 26 '17 at 23:18
• The infinite product $\prod_{m=1}^\infty (1+x^m)$ is a modular function. The finite product $\prod_{m=1}^n (1+x^m)$ is not, and truncating the product at the $n$th term reduces the $x^{(n^2+n)/4}$ coefficient once $n>3$, so the Rademacher formula gives only an upper bound for the enumeration that Mr. Newman asked for. – Noam D. Elkies Sep 27 '17 at 5:05
• Probably about as intractable for getting exact answers, though an asymptotic formula is again known. Apparently this version is less studied: the same route, via for(n=1,20,print([n,polcoeff(prod(m=1,2*n,1+x^(2*m-1)),2*n^2)])) , leads to oeis.org/A292476 and thence to oeis.org/A156700 but there's not nearly as much information there as there was on your original question. – Noam D. Elkies Sep 27 '17 at 18:19