TITLE: Number of choices of signs: $\pm 1 \pm 2 \pm ... \pm n=0$
QUESTION [13 upvotes]: Here is an interesting problem I thought of.
In how many ways can we choose the $n$ $\pm$ signs in the equation below: 
$\pm 1 \pm 2 \pm ... \pm n=0$
It has been made apparent to me that in fact the number of solutions is 
$$
\frac{1}{2\pi} \int_0^{2\pi} \prod_{k=1}^{n} 2\cos(kx) dx
$$
I find this result interesting and so:
1)How can we prove that result?
2)Does the integral have a closed form? We know that $f(n)=0$ for $n$ is $1,2$ mod $4$ by parity considerations, but for general $n$ I would be suprised if a closed form exists.
EDIT: It has been made apparent that we can prove the identity more easily than in the answer below by using generating functions. In particular consider the product of $z^k+z^{-k}$ over the appropriate values of $k$, and note the connection to complex numbers on the unit circle. Don't want to give too many more details, but you will have to substitute $z=e^{ix}$ I think. I challenge you to fill in the details (I know how to do it myself now).

REPLY [4 votes]: Suppose
$$
\sum_{k=1}^n\pm k=0\tag{1}
$$
Since
$$
\sum_{k=1}^nk=\frac{n^2+n}2\tag{2}
$$
both the sum of the positive and the sum of the negative terms must be $\frac{n^2+n}4$. Thus, $(1)$ has no solution for $n\equiv1,2\pmod{4}$ since for those $n$, $\frac{n^2+n}4\not\in\mathbb{Z}$.
The number of solutions to $(1)$ is the coefficient of $x^0$, the constant coefficient, in
$$
\prod_{k=1}^n\left(x^k+x^{-k}\right)\tag{3}
$$
which is
$$
\frac1{2\pi}\int_0^{2\pi}\prod_{k=1}^n\left(e^{ikx}+e^{-ikx}\right)\mathrm{d}x
=\bbox[5px,border:2px solid #C0A000]{\frac1{2\pi}\int_0^{2\pi}\prod_{k=1}^n2\cos(kx)\,\mathrm{d}x}\tag{4}
$$