In how many ways can the integers from $1$ to $n$ be divided into two groups with the same sum?

Solution 1:

Obviously $1+2+\ldots+n = \frac{n(n+1)}{2}$ has to be an even number (hence that is possible only for $n\in\{0,3\}\pmod{4}$) and in such a case the answer is given by half the coefficient of $x^{\frac{n(n+1)}{4}}$ in the product $$ \prod_{k=1}^{n}\left(1+x^k\right). $$ See partition function and this article. In the case $n=7$, the answer is just $\color{red}{4}$.