Double sum of products of integers up to $n$ Suppose that $S$ is defined by
$$
S(n) = \sum_{i=0}^{n} \sum_{j=0}^{i} ij.
$$
I'm confused as to how $S(3) = 25$ from this summation.  Can anyone expand on it as to how to get the answer? 
 A: \begin{align*}
  S(3) &= \sum_{i=0}^3\sum_{j=0}^i ij \\
       &= 0\sum_{j=0}^0 j + 1\sum_{j=0}^1 j + 2\sum_{j=0}^2 j + 3\sum_{j=0}^3 j \\
       &= 0 + (0+1) + 2(0+1+2) + 3(0+1+2+3) \\
       &= 25.
\end{align*}
More generally,
\begin{align*}
  S(n) &= \sum_{i=0}^n\sum_{j=0}^i ij \\
       &= \sum_{i=0}^n i\cdot\frac{i(i+1)}{2} \\
       &= \frac{1}{2}\sum_{i=0}^n i^3+i^2 \\
       &= \frac{1}{2}\left(\frac{n^2(n+1)^2}{4} + \frac{n(n+1)(2n+1)}{6}\right) \\
       &= \frac{1}{24}(3 n^4+10 n^3+9 n^2+2 n).
\end{align*}
A: Here's a table of the values, where the row is indexed by $i$ and the column is indexed by $j$:
$$
\begin{array}{c|rrrr}
ij & 0 & 1 & 2 & 3 \\
\hline
0 & 0 \cdot 0 & & & \\
1 & 1 \cdot 0 & 1 \cdot 1 & & \\
2 & 2 \cdot 0 & 2 \cdot 1 & 2 \cdot 2 & \\
3 & 3 \cdot 0 & 3 \cdot 1 & 3 \cdot 2 & 3 \cdot 3 
\end{array}
$$
The way the sum written in your definition of $S$ suggests summing across the rows, so
$$
S(3) = 0(0) + 1(0+1) + 2(0+1+2) + 3(0+1+2+3) = 25.
$$
However, it's worth mentioning that sometimes sums over two indices are easier to evaluate by "transposing" them.  (I don't claim that it's easier in this particular sum, but it's useful to see this in action.)  In this situation, you would read down the columns:
$$
S(3) = (0+1+2+3)0 + (1+2+3)1 + (2+3)2 + (3)3 = 25.
$$
In other words, this is an equivalent way to write the definition of $S$:
$$
S(n) = \sum_{j=0}^{n} \sum_{i=j}^n ij.
$$
