# Bachet's Magic Trick

Let N be an integer. This is the lone number at the bottom of the applet below. It can be modified by clicking on it. Currently it is 4. For practical reasons, it can change between 3 and 6, inclusive.

The integers from 1 through N·(N+1) are split into pairs. Select one pair (not just two integers but a pair among the pairs of integers the applet displays). Remember this pair, think hard of it with complete concentration, click the Proceed button. The same numbers will now be arranged in a N×(N+1) array. By just pointing to the two rows in which your selected numbers are located (if the numbers are in the same row, select it twice) you give your computer enough information to guess your numbers. Try it!

### This applet requires Sun's Java VM 2 which your browser may perceive as a popup. Which it is not. If you want to see the applet work, visit Sun's website at https://www.java.com/en/download/index.jsp, download and install Java VM and enjoy the applet.

 What if applet does not run?

Explanation

## Bachet's Magic Trick

The number of distinct pairs in which N objects may be combined is N·(N+1)/2. For example, if N = 4, there are 10 pairs: {1, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}, {2, 3}, {2, 4}, {3, 3}, {3, 4}, and {4, 4}, with each object appearing 5 (in general, N + 1) times.

Two sets of such pairs could be arranged in an N×(N+1) array in a peculiar manner. For example, for N = 4, we have

 {1, 1} {1, 1} {1, 2} {1, 3} {1, 4} {2, 1} {2, 2} {2, 2} {2, 3} {2, 4} {3, 1} {3, 2} {3, 3} {3, 3} {3, 4} {4, 1} {4, 2} {4, 3} {4, 4} {4, 4}
or
 {1, 1} {1, 1} {1, 2} {1, 3} {1, 4} {2, 1} {2, 2} {2, 2} {2, 3} {2, 4} {3, 1} {3, 2} {3, 3} {3, 3} {3, 4} {4, 1} {4, 2} {4, 3} {4, 4} {4, 4}

where in the left half of the table I reversed the order of numbers in a pair. It is now clear that for a pair on the left, the first number points to the row, while the second to the column, in which the pair is located. Additionally, the second number points to the row in which the companion pair (i.e., the one with the original order of numbers) could be found. (Incidentally, its column number is one more than the row number of the left pair.) This means that the location of the latter is uniquely determined by the row numbers of the two pairs as is the location of the original pair.

Let's now label the 20 pairs with 20 numbers. If the left pair {row, col} is associated with n and the right pair {col, row} with m, we can say that both, or the defining one {row, col} is associated with the pair (n, m). Naturally then, given the two rows in which the numbers n and m are located, it is very easy to determine both of them.

To see how the association works, check the "Straight list" and uncheck the "Randomize" button in the applet below.

### This applet requires Sun's Java VM 2 which your browser may perceive as a popup. Which it is not. If you want to see the applet work, visit Sun's website at https://www.java.com/en/download/index.jsp, download and install Java VM and enjoy the applet.

 What if applet does not run?

"Straight list" assigns the labels in a straightforward manner, such that the ordering of the pairs in the array becomes obvious. Otherwise, they are labeled in a random manner.

The "Randomize" button confounds the simplicity of the situation. Since all that is important is the rows of the two numbers, they may be located anywhere in the rows. When the randomize button is checked, the number are randomly permuted in every row just before being displayed in the array and, in addition, the numbers in a pair may occasionally swap rows.

[Rouse Ball, p. 326-328] refers the problem and the particular arrangement of pairs of objects to the classical Problèmes plaisans et délectables by a pioneer of recreational mathematics Claude Gaspar Bachet, sieur de Méziriac (the 1st edition published in 1612, the 2nd in 1624.)

### References

1. W. W. Rouse Ball, H. S. M. Coxeter, Mathematical Recreations and Essays, Dover, 1987

• An Arithmetic Magic Trick
• Gergonne's Magic Trick