# Mathematical justification of this "34" array trick

Frequently my son's teacher will show him fun little math "tricks." I usually take this as a moment to show him what's really underlying the trick (e.g., why two consecutive squares will differ by a predictable odd number). However, the most recent one is eluding me.

Consider the square array $$\begin{matrix} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ 9 & 10 & 11 & 12 \\ 13 & 14 & 15 & 16. \end{matrix}$$

The process is to select entries based on Latin-square-type rules. So, choose a number $$x_1$$ from the first row. Now pick a number $$x_2$$ from row $$2$$, with the stipulation that you may not pick from the column containing entry $$x_1$$. Pick $$x_3$$ from row $$3$$ with the same stipulations: you may not select from either of the columns containing $$x_1$$ or $$x_2$$. The final entry $$x_4$$ from row $$4$$ is now dictated. The claim is that $$x_1+x_2+x_3+x_4=34$$ regardless of the choices you made.

I could certainly brute force this and verify the claim, but that's not very fun. I am looking for a more elegant, algebraic explanation. I've tried making some little algebraic re-writes. If $$x_1 = k$$ where $$k$$ is the column number $$x_1$$ is selected from, then $$x_2=4+k$$ is then impossible. However, this doesn't help me cover the three actual possible values for $$x_2$$. The problem then compounds as I move to row $$3$$.

There is certainly some little algebraic tidbit that is making this work, but I don't see it yet. So what is the slick argument that all legal sums will be $$34$$?

• Might be a fun exercise to compute the "magic sum" value for the generic nxn square (I assume he's seen the "little boy Gauss" sum trick).
– usul
Commented May 1 at 10:44
• Another potentially interesting exercise, if you drop the constraint that the numbers be consecutive, for a given target total, construct a similar square such that the result of this process always equals that target. Commented May 1 at 16:08
• Also (for fun) you can pick number from the first column, the second column, etc (ie swap "row" and "column") and they will still add to 34 for the same reason :-) Commented May 2 at 1:21

Each of the row has 'remainders' $$1$$, $$2$$, $$3$$ or $$4$$ from the previous multiple of $$4$$. So, really the table is $$\begin{matrix} 0+1&0+2&0+3&0+4\\ 4+1&4+2&4+3&4+4\\ 8+1&8+2&8+3&8+4\\ 12+1&12+2&12+3&12+4 \end{matrix}$$ Whatever choice you make, you are gonna pick each remainder exactly once. So, the sum is just $$(0+4+8+12)+(1+2+3+4)=34$$.

Hope this helps. :)

• OMG I knew it was something simple like this! Excellent. Commented Apr 30 at 12:06
• + 1 I intuitively "saw" the solution as the total of the first column plus (0 + 1 + 2 + 3), which of course leads to the same answer.
– Jos
Commented May 1 at 10:19
• It might be fun to explore with the student what kinds of changes you can make and keep this property. For instance, you can reorder rows, or reorder columns, but you can't reorder the columns within just one row, or the rows within just one column. Commented May 1 at 14:24
• Put another way, the entry in the $i$th row and $j$th column is $4(i-1)+j$, and so the sum will equal $\sum_{i=1}^4 4(i-1) + \sum_{j=1}^4 j$ no matter what Latin-square choices are made. In the generalization to $n\times n$ squares, the sum will always equal $\sum_{i=1}^n n(i-1) + \sum_{j=1}^n j = \frac12(n^3+n)$. Commented May 1 at 19:21

## Graphically, ...

... we have this:

a: *
b: **
c: ***
d: ****

a: **** *
b: **** **
c: **** ***
d: **** ****

a: **** **** *
b: **** **** **
c: **** **** ***
d: **** **** ****

a: **** **** **** *
b: **** **** **** **
c: **** **** **** ***
d: **** **** **** ****


You must pick a bar from each group of 4, but it must be a different one: if you pick a from a group, you must not pick a from any other group.

So, for instance, from the third group, you are effectively choosing the common base **** ****, plus one piece of the triangle

*
**
***
****


In the end, your selection contains the three bars ****, **** **** and **** **** ****, which add up to 24. Plus, your selection contains a complete triangle, which contains 10 asterisks. That adds up to 34.

Whatever change you make to the selection has no effect on the sum. For instance, if from the second row of the matrix, you choose the fourth entry instead of the third, that adds 1 to the sum. But a compensating change has to be made in another row: in another row, you will have to choose the third entry instead of the fourth in order to comply with the selection rules. That will subtract 1 from the sum, keeping it at 34.

## By induction, ...

We have this base case:

(1)  2   3   4
5  (6)  7   8
9  10 (11) 12
13  14  15 (16)


By inspection, these diagonal numbers add up to 34. They meet the selection criteria: each one is a different column. So that's our induction base case.

Now, suppose we make a change to the selection of any row:

(1)  2   3   4
5   6   7  (8)
9  10 (11) 12
13  14  15 (16)!!!


We selected 8 instead of 6. This adds 2 to the sum, making it 36. However, we are breaking the rules now because 8 clashes with 16. To repair this we must select 14 instead of 16:

(1)  2   3   4
5   6   7  (8)
9  10 (11) 12
13 (14) 15  16


But 14 instead of 16 decreases the sum by 2, bringing it back to 34.

Every possible selection can be made by a sequence of such exchanges, which preserve the sum. Informal proof: for any selection i, j, k, l, we can simply work from top to bottom, moving the selection to the desired figure, and then correcting the clashing row below. We select i in the first row, then find the clashing row below, exchanging the selection with that one. Then we do that for the second and third rows. The fourth row is left with l being selected.

For instance, we can select the reverse diagonal, by starting with this:

 (1)  2   3   4
5   6   7  (8)
9  10 (11) 12
13 (14) 15  16


Then exchange the parentheses between rows 1 and 2:

  1   2   3  (4)
(5)  6   7   8
9  10 (11) 12
13 (14) 15  16


The sum gains and loses 3, maintaining at 34. Then we exchange the parentheses of rows 2 and 3:

  1   2   3  (4)
5   6  (7)  8
(9) 10  11  12
13 (14) 15  16


and finally those of 3 and 4:

  1   2   3  (4)
5   6  (7)  8
9 (10) 11  12
(13) 14  15  16


At each exchange, the sum stays the same because whatever we credit in one row we debit in another.

You can also take the average of each row, since you can not choose the same column twice, and add them up: 2,5 + 6,5 + 10,5 + 14,5 = 34

...but I do like ultralegend5385's answer better, though.

• It also works when using column-averages. Commented May 2 at 14:40

Here is another way of looking at it. The number in the $$(i,j)$$ square is $$4(i-1)+j$$.

Picking the numbers is equivalent to selecting $$j_1,...,j_4$$ corresponding to the column for row $$i=1,...,4$$. The only proviso is that the $$j_k$$ are distinct. However, we always have (by sorting the numbers) $$j_1+...+j_4 = 1+...+4 = 10$$.

Then the sum of the numbers is $$\sum_{i=1}^4 4(i-1)+j_i = \sum_{i=1}^4 4(i-1)+ \sum_{i=1}^4 j_i = 24+10$$.

• How is that "another" way of looking at it than the other answer, beyond more notation? Commented May 1 at 4:29
• Not sure I get the negativity here. Commented May 1 at 15:01
• A bit of formalism in notation is valuable as another answer.
– qwr
Commented May 2 at 3:34