TITLE: Given i+j+k=n, find sum of all possible ijk
QUESTION [8 upvotes]: Just solved this question, correctly (made a computer program to, successfully, verify the formula that I got):
Let $S$ denote the set of triples $(i,j,k)$ such that $i+j+k=n$ and $i,j,k\in\mathbb{N}$.
Evaluate $$\sum_{(i,j,k)\in S}ijk$$
My solution was as follows:
I'll assume that $i,j,k\in\mathbb{N}_0$ and $(i,j,k)$ is an ordered triple (eg. $(1,2,0)\not\equiv(0,2,1)$)
WLOG consider $i$ as it varies. Firstly as a sub-problem (for ease of understanding) fix $i=0\implies j+k=n$. Now this sub-problem reduces to finding all unordered pairs $(j,k)$ such that $j+k=n$, to then find $jk$ for each.
Notice that if $j+k=N$ for some $N\in\mathbb{N}$, then $\exists \ N+1$ such pairs, which are $(0,N),(1,N-1),(2,N-2),\ldots,(N-1,1),(N,0)$. So the sum of all our $jk$ is given by, generally as $N$ varies
$$
\sum_{j=0}^{N}j(N-j)
$$
For $i=0$ we have $N=n$, and the desired sum will be
$$
0\times\sum_{j=0}^{n}j(n-j)
$$
Now the sub-problem can easily be generalised to the main problem, as all that is different is that as $i$ varies, we must vary $N$ with it. specifically, if $i=b$ then $N=n-b$. So we will obtain a double sum.
$$
\begin{align}
\therefore \sum_{(i,j,k)\in S}ijk
&=\sum_{i=0}^{n}i\sum_{j=0}^{n-i}j(n-i-j)
\\ &=\sum_{i=0}^{n}i\left((n-i)\sum_{j=0}^{n-i}j-\sum_{j=0}^{n-i}j^2\right)
\\ &= \sum_{i=0}^{n}i\left((n-i)(\frac 1 2 (n-i)(n-i+1))-\frac 1 6 (n-i)(n-i+1)(2(n-i)+1)\right)
\\ &= \sum_{i=0}^{n}i\left(\frac 1 2 (n-i)^2(n-i+1)-\frac 1 6 (n-i)(n-i+1)(2n-2i+1)\right)
\\ &= \sum_{i=0}^{n}i\left(\frac 1 6 (n-i)(n-i+1)(3(n-i)-(2n-2i+1))\right)
\\ &= \frac 1 6 \sum_{i=0}^{n}i(n-i)(n-i+1)(n-i-1)
\\ &= \frac 1 6 \sum_{i=0}^{n}i(n-i)((n-i)^2-1)
\\ &= \frac 1 6 \sum_{i=0}^{n}i((n-i)^3-(n-i))
\\ &= \frac 1 6 \sum_{i=0}^{n}i(n^3-3n^2i+3ni^2-i^3-n+i)
\\ &= \frac 1 6 \sum_{i=0}^{n}n(n+1)(n-1)i+(1-3n^2)i^2+3ni^3-i^4
\\ &= \frac 1 6 n(n+1)(n-1) \sum_{i=0}^{n}i+\frac 1 6 (1-3n^2) \sum_{i=0}^{n}i^2+\frac 1 2 n \sum_{i=0}^{n}i^3- \frac 1 6 \sum_{i=0}^{n}i^4
\\ &= \frac 1 {12} n^2(n+1)^2(n-1)+\frac 1 {36} n(n+1)(2n+1)(1-3n^2)+\frac 1 {8} n^3(n+1)^2 - \frac 1 {180} n(n+1)(2n+1)(3n^2+3n-1)
\\ &= (\frac 1 {12} n^5 + \frac 1 {12} n^4 - \frac 1 {12} n^3 - \frac 1 {12} n^2) +  (-\frac 1 {6} n^5 - \frac 1 {4} n^4 - \frac 1 {12} n^2 + \frac 1 {36} n) + (\frac 1 {8} n^5 + \frac 1 {4} n^4 + \frac 1 {8} n^3) - (\frac 1 {30} n^5 + \frac 1 {12} n^4 +\frac 1 {18} n^3 -\frac 1 {180} n)
\\ &= \frac{1}{120}n^5-\frac{1}{24}n^3+\frac{1}{30}n
\\ &= \frac{1}{120}n(n^4-5n^2+4)
\\ &= \frac{1}{120}n(n^2-1)(n^2-4)
\\ &= \frac{1}{120}n(n+1)(n-1)(n-2)(n+2)
\\ &= \frac{(n+2)!}{(n-3)!5!}
\\ &= \binom{n+2}{5}
\end{align}
$$
My question was, how come there is a binomial coefficient as an answer? Are there any cool generalisations/patterns here? It seems unexpected (to me) that a sum of ijk would come out as that, and quite nice, but I can't seem to relate it to anything binomial related.

REPLY [6 votes]: Observe that
$$\frac{X}{(1-X)^2}=\sum_{i=1}^\infty iX^i.$$
(At least for small $X$.)
Therefore
$$\frac{XYZ}{(1-X)^2(1-Y)^2(1-Z)^2}=\sum_{i,j,k=1}^\infty ijkX^iY^jZ^k.$$
Setting $X=Y=Z$ gives
$$\frac{X^3}{(1-X)^6}=\sum_{i,j,k=1}^\infty ijkX^{i+j+k}=\sum_{n=3}^\infty a_n X^n$$
where
$$a_n=\sum_{i+j+k=n}ijk.$$
As
$$\frac1{(1-X)^6}=\sum_{n=0}^\infty\binom{n+5}5X^n$$
we get
$$a_n=\binom{n+2}5.$$
This argument will extend to sums like
$$\sum_{i_1+\cdots+i_r=n}i_1\cdot \cdots \cdot i_r.$$