Consider the sum of the following three tables. The first represents $n$ rows, with the first row containing $n$ numbers equal to $n$, the second row containing $n-1$ numbers equal to $n-1$, and so on. In the second table, we have a similar distribution of numbers, but in columns instead of rows. In the third table, these numbers are arranged in diagonals, with the first diagonal containing one number 1, the second diagonal containing two numbers equal to 2, the third diagonal containing three numbers equal to 3, and so on.

![](https://cdn.mathpix.com/cropped/2024_05_01_40ea5c1759d4b041c087g-11.jpg?height=282&width=1418&top_left_y=1638&top_left_x=422)

The result of summing the three tables will be a table with the same number of numbers, where each position is the result of summing the corresponding positions in the three tables. For example, in the upper left corner, we will have the number $n+n+1=2n+1$.

(a) One way to check how many numbers are in each table is to turn one of them upside down and join it with another to form a rectangle with $n$ rows and twice the number of numbers in one table. Knowing this, how many numbers are there in one table?

(b) How many times does each number $k$ appear in all three tables?

(c) For each position, row $i$ and column $j$, determine the numbers written in it in the three tables and in the resulting table.

(d) Using the information from the previous items, verify that

$$
1^{2}+2^{2}+3^{2}+\ldots+(n-1)^{2}+n^{2}=\frac{1}{6} n(n+1)(2 n+1)
$$
Solution

(a) By flipping one of them upside down and joining it with another, we form a rectangle $n \times (n+1)$. Since this rectangle contains twice the number of elements of one table, each of them has $\frac{n(n+1)}{2}$ numbers.

(b) Each number $k$ appears $k$ times in the first table, $k$ times in the second, and $k$ times in the third. Therefore, each number $k$ appears $3k$ times in total.

(c) In the first table, the row determines the value of that position. Since the initial number $n$ is reduced by one unit for each row further down, in row $i$ and column $j$ we will have $n+1-i$. Using the same reasoning for the second table, in row $i$ and column $j$ we will have the number $n+1-j$. In the third table, observe that the positions associated with elements of a diagonal have a constant sum of their row and column. Additionally, the number written in a cell of a diagonal is one unit less than this constant. Therefore, in row $i$ and column $j$ we will have $i+j-1$. In the result table, the number will be

$$
(n+1-i)+(n+1-j)+(i+j-1)=2n+1
$$

(d) Using the previous items, we notice that the result table has $\frac{n(n+1)}{2}$ elements equal to $2n+1$. Thus, we can sum the numbers of the three given tables in two different ways: by summing each number $k$ in the three tables or by summing the numbers in the result table. Therefore,

$$
\begin{aligned}
(3 \cdot 1) \cdot 1 + (3 \cdot 2) \cdot 2 + \ldots + (3 \cdot n) \cdot n & = \frac{n(n+1)}{2} \cdot (2n+1) \\
3(1^2 + 2^2 + 3^2 + \ldots + (n-1)^2 + n^2) & = \frac{1}{2} n(n+1)(2n+1) \\
1^2 + 2^2 + 3^2 + \ldots + (n-1)^2 + n^2 & = \frac{1}{6} n(n+1)(2n+1)
\end{aligned}
$$