PG26839.B00136
[PDF page 135] CH. IV] PROBLEMS CONNECTED WITH A PACK OF CARDS. 119 suppose that an écarté pack of32 cards is dealt into4 piles each of8 cards, and that the pile which contains some selected card is picked up ath. Suppose that on dealing again into four piles, one pile is indicated as containing the selected card, the selected card cannot be one of the bottom 2(a − 1) cards, or of the top 8 − 2a cards, but must be one of the intermediate 2 cards, and the trick can be finished in any way, as for instance by the common conjuring ambiguity of asking someone to choose one of them, leaving it doubtful whether the one he takes is to be rejected or retained. The Mouse Trap. I will conclude this chapter with the bare mention of another game of cards, known as themouse trap, the dis- cussion of which involves some rather difficult algebraic analysis. It is played as follows. A set of cards, marked with the numbers 1, 2, 3, . . . , n, is dealt in any order, face upwards, in the form of a circle. The player begins at any card and counts round the circle always in the same direction. If thekth card has the numberk on it—which event is called ahit—the player takes up the card and begins counting afresh. According to Cayley, the player wins if he thus takes up all the cards, and the cards win if at any time the player counts up ton without being able to take up a card. For example, if a pack of only four cards is used and these cards come in the order,3214, then the player would obtain the second card 2 as a hit, next he would obtain 1 as a hit, but if he went on for ever he would not obtain another hit. On the other hand, if the cards in the pack were initially in the order1423, the player would obtain successively all four cards in the order1, 2, 3, 4. The problem may be stated as the determination of what hits and how many hits can be made with a given number of cards; and what permutations will give a certain number of hits in a certain order. Cayley* showed that there are 9 arrangements of a pack of four cards in which no hit will be made,7 arrangements in which only one hit will be made,3 arrangements in which only two hits will be made, and 5 arrangements in which four hits will be made. Prof. Steen† has investigated the general theory for a pack ofn cards. He has shown how to determine the number of arrangements in * Quarterly Journal of Mathematics, 1878, vol.xv, pp. 8–10. † Ibid., vol. xv, pp. 230–241.

PG26839.B00137
[PDF page 136] 120 MISCELLANEOUS MATHEMATICAL RECREATIONS. [CH. IV which x is the first hit [Arts. 3–5]; the number of arrangements in which 1 is the first hit andx is the second hit [Art. 6]; and the number of arrangements in which2 is the first hit andx the second hit [Arts. 7–8]; but beyond this point the theory has not been carried. It is obvious that, if there aren − 1 hits, the nth hit will necessarily follow. Treize. The French game oftreize is very similar. It is played with a full pack of fifty-two cards (knave, queen, and king counting as 11, 12, and 13 respectively). The dealer calls out1, 2, 3, . . . ,13, as he deals the 1st, 2nd, 3rd, . . ., 13th cards respectively. At the beginning of a deal the dealer offers to lay or take certain odds that he will make a hit in the thirteen cards next dealt. One of the innumerable forms ofpatienceis played in a similar way.

PG26839.B00138
[PDF page 137] CHAPTER V. MAGIC SQUARES. A magic square consists of a number of integers arranged in the form of a square, so that the sum of the numbers in every row, in every column, and in each diagonal is the same. If the integers are the consecutive numbers from1 to n2 the square is said to be of thenth order, and it is easily seen that in this case the sum of the numbers in any row, column, or diagonal is equal to1 2 n(n2 + 1): this number may be denoted byN. I confine my account to such magic squares, that is, to squares formed with consecutive integers, from1 upwards. Thus the first16 integers, arranged in either of the forms given in figures i and ii below, form a magic square of the fourth order, the sum 1 15 14 4 12 6 7 9 8 10 11 5 13 3 2 16 Figure i. 15 10 3 6 4 5 16 9 14 11 2 7 1 8 13 12 Figure ii. of the numbers in any row, column, or diagonal being34. Similarly figures iii and v on page 124, figure viii on page 126, and figures xii and xiii on page 136, show magic squares of the fifth order; and figure xi on page 133 shows a magic square of the sixth order; and figures xiv and xv on pages 137, 138, show magic squares of the eighth order. 121

PG26839.B00139
[PDF page 138] 122 MAGIC SQUARES. [CH. V The formation of these squares is an old amusement, and in times when mystical philosophical ideas were associated with particular num- bers it was natural that such arrangements should be deemed to possess magical properties. Magic squares of an odd order were constructed in India before the Christian era according to a law of formation which is explained hereafter. Their introduction into Europe appears to have been due to Moschopulus, who lived at Constantinople in the early part of the fifteenth century, and enunciated two methods for making such squares. The majority of the medieval astrologers and physicians were much impressed by such arrangements. In particular the famous Cor- nelius Agrippa (1486–1535) constructed magic squares of the orders3, 4, 5, 6, 7, 8, 9, which were associated respectively with the seven as- trological “planets”: namely, Saturn, Jupiter, Mars, the Sun, Venus, Mercury, and the Moon. He taught that a square of one cell, in which unity was inserted, represented the unity and eternity of God; while the fact that a square of the second order could not be constructed illustrated the imperfection of the four elements, air, earth, fire, and water; and later writers added that it was symbolic of original sin. A magic square engraved on a silver plate was sometimes prescribed as a charm against the plague, and one, namely, that represented in figure i on page 121, is drawn in the picture of Melancholy, painted about the year 1500 by Albert Dürer. Such charms are still worn in the East. The development of the theory has been due mainly to French mathematicians. Bachet gave a rule for the construction of any square of an odd order in a form substantially equivalent to one of the rules given by Moschopulus. The formation of magic squares, especially of even squares, was considered by Frénicle and Fermat. The theory was continued by Poignard, De la Hire, Sauveur, D’Ons-en-bray, and Des Ourmes. Ozanam included in his work an essay on magic squares which was amplified by Montucla. From this and from De la Hire’s memoirs the larger part of the materials for this chapter are derived. Like most algebraical problems, the construction of magic squares at- tracted the attention of Euler, but he did not advance the general theory. In 1837 an elaborate work on the subject was compiled by B. Violle, which is useful as containing numerous illustrations. I give the references in a footnote*. * Bachet, Problèmes plaisans, Lyons, 1624, problemxxi, p. 161; Frénicle,Divers Ouvrages de Mathématique par Messieurs de l’Académie des Sciences, Paris,

PG26839.B00140
[PDF page 139] CH. V] MAGIC SQUARES OF AN ODD ORDER.. 123 I shall confine myself to establishing rules for the construction of squares subject to no conditions beyond those given in the definition. Rules sufficient for this purpose are contained in the works to which I have just referred and on which I have based this sketch; some ex- tensions and developments will be found in the memoirs mentioned below*. I shall commence by giving rules for the construction of a square of an odd order, and then shall proceed to similar rules for one of an even order. It will be convenient to use the following terms. The spaces or small squares occupied by the numbers are calledcells. The diagonal from the top left-hand cell to the bottom right-hand cell is called the leading diagonalor left diagonal. The diagonal from the top right-hand cell to the bottom left-hand cell is called theright diagonal. MagicSquaresofanoddorder. Iproceedtogivemethods for constructingodd magic squares, but for simplicity I shall apply them to the formation of squares of the fifth order, though exactly similar 1693, pp. 423–483; with an appendix (pp. 484–507), containing diagrams of all the possible magic squares of the fourth order, 880 in number: Fermat, Opera Mathematica, Toulouse, 1679, pp. 173–178; or Brassinne’sPrécis, Paris, 1853, pp. 146–149: Poignard,Traité des Quarrés Sublimes, Brussels, 1704: De la Hire, Mémoires de l’Académie des Sciencesfor 1705, Paris, 1706, part i, pp. 127–171; partii, pp. 364–382: Sauveur,Construction des Quarrés Mag- iques, Paris, 1710: D’Ons-en-bray,Mémoires de l’Académie des Sciencesfor 1750, Paris, 1754, pp. 241–271: Des Ourmes,Mémoires de Mathématique et de Physique (French Academy), Paris, 1763, vol.iv, pp. 196–241: Ozanam and Montucla, Récréations, part i, chapter xii: Euler, Commentationes Arithmeti- cae Collectae, St Petersburg, 1849, vol.ii, pp. 593–602: Violle,Traité Complet des Carrés Magiques, 3 vols, Paris, 1837–8. A sketch of the history of the subject is given in chap. iv of S. Günther’sGeschichte der mathematischen Wis- senschaften, Leipzig, 1876. See also W. Ahrens,Mathematische Unterhaltungen und Spiele, Leipzig, 1901, chapter xii. * In England the subject has been studied by R. Moon,Cambridge Mathematical Journal, 1845, vol. iv, pp. 209–214; H. Holditch,Quarterly Journal of Math- ematics, London, 1864, vol. vi, pp. 181–189; W.H. Thompson,Ibid., 1870, vol. x, pp. 186–202; J. Horner,Ibid., 1871, vol. xi, pp. 57–65, 123–132, 213– 224; S.M. Drach,Messenger of Mathematics, Cambridge, 1873, vol.ii, pp. 169– 174, 187; A.H. Frost,Quarterly Journal of Mathematics, London, 1878, vol.xv, pp. 34–49, 93–123, 366–368, in which the results of previous memoirs are in- cluded: there are also some pamphlets and articles on it of a more popular character. Of recent Continental works on the subject I have no complete bib- liography, and probably it is better to omit all rather than give an imperfect list.

PG26839.B00141
[PDF page 140] 124 MAGIC SQUARES. [CH. V proofs will apply equally to any odd square. De la Loubère’s Method*. If the reader will look at figure iii he will see one way in which such a square containing25 cells can be constructed. The middle cell in the top row is occupied by 1. The successive numbers are placed in their natural order in a diagonal line 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 De la Loubère’s Method. Figure iii. 15 + 2 20 + 4 0 + 1 5 + 3 10 + 5 20 + 3 0 + 5 5 + 2 10 + 4 15 + 1 0 + 4 5 + 1 10 + 3 15 + 5 20 + 2 5 + 5 10 + 2 15 + 4 20 + 1 0 + 3 10 + 1 15 + 3 20 + 5 0 + 2 5 + 4 De la Loubère’s Method. Figure iv. 23 6 19 2 15 10 18 1 14 22 17 5 13 21 9 4 12 25 8 16 11 24 7 20 3 Bachet’s Method. Figure v. which slopes upwards to the right, except that (i) when the top row is reached the next number is written in the bottom row as if it came immediately above the top row; (ii) when the right-hand column is reached, the next number is written in the left-hand column, as if it immediately succeeded the right-hand column; and (iii) when a cell which has been filled up already, or when the top right-hand square is reached, the path of the series drops to the row vertically below it and then continues to mount again. Probably a glance at the diagram in figure iii will make this clear. The reason why such a square is magic can be explained best by expressing the numbers in the scale of notation whose radix is5 (or n, if the magic square is of the ordern), except that5 is allowed to appear as a unit-digit and0 is not allowed to appear as a unit-digit. The result is shown in figure iv. From that figure it will be seen that the method of construction ensures that every row and every column shall contain one and only one of each of the unit-digits1, 2, 3, 4, 5, the sum of which is 15; and also one and only one of each of the radix-digits0, 5, 10, 15, 20, the sum of which is50. Hence, as far as rows and columns are concerned, the square is magic. Moreover if the square is odd, each of the diagonals will contain one and only one of each of the unit-digits 1, 2, 3, 4, 5. Also the leading diagonal will contain one and only one * De la Loubère, Du Royaume de Siam (Eng. Trans.), London, 1693, vol. ii, pp. 227–247. De la Loubère was the envoy of Louis XIV to Siam in 1687–8, and there learnt this method.

PG26839.B00142
[PDF page 141] CH. V] MAGIC SQUARES OF AN ODD ORDER.. 125 of the radix-digits0, 5, 10, 15, 20, the sum of which is50; and if, as is the case in the square drawn above, the number10 is the radix-digit to be added to the unit-digits in the right diagonal, then the sum of the radix-digits in that diagonal is also50. Hence the two diagonals also possess the magical property. And generally if a magic square of an odd ordern is constructed by De la Loubère’s method, every row and every column must contain one and only one of each of the unit-digits1, 2, 3 . . . , n; and also one and only one of each of the radix-digits0, n,2n, . . . , n(n − 1). Hence, as far as rows and columns are concerned, the square is magic. Moreover each diagonal will either contain one and only one of the unit-digits or will contain n unit-digits each equal to1 2(n + 1). It will also either contain one and only one of the radix-digits or will containn radix-digits each equalto 1 2 n(n−1). Hencethetwodiagonalswillalsopossessthemagical property. Thus the square will be magic. I may notice here that, if we place1in any cell and fill up the square by De la Loubère’s rule, we shall obtain a square that is magic in rows and in columns, but it will not in general be magic in its diagonals. It is evident that other squares can be derived from De la Loubère’s square by permuting the symbols properly. For instance, in figure iv, we may permute the symbols 1, 2, 3, 4, 5 in 5! ways, and we may permute the symbols 0, 5, 15, 20 in 4! ways. Any one of these 5! arrangements combined with any one of these4! arrangements will give a magic square. Hence we can obtain2880 magic squares of the fifth order of this kind, though only720 of them are really distinct. Other squares can however be deduced, for it may be noted that from any magic square, whether even or odd, other magic squares of the same order can be formed by the mere interchange of the row and the column which intersect in a cell on a diagonal with the row and the column which intersect in the complementary cell of the same diagonal. Bachet’s Method*. Another method, very similar to that of De la Loubère, for constructing an odd magic square is as follows. We begin by placing1 in the cell above the middle one (that is, in a square of the fifth order in the cell occupied by the number7 in figure iii), and then we write the successive numbers in a diagonal line sloping upwards to the right, subject to the condition that when the cases (i) and (ii) mentioned under De la Loubère’s method occur the rules there * Bachet, Problem xxi, p. 161.

PG26839.B00143
[PDF page 142] 126 MAGIC SQUARES. [CH. V given are followed, but when the case (iii) occurs the path of the series rises two rows, i.e. it is continued from one cell to the cell next but one vertically above it, if this cell is above the top row the path continues from the corresponding cell in one of the bottom two rows following the analogy of rule (i) in De la Loubère’s method. Such a square is delineated in figure v on page 124. Bachet’s method leads ultimately to this arrangement; except that the rules are altered so as to make the line slope downwards. This method also gives720 magic squares of the fifth order. De la Hire’s Method*. I shall now give another rule for the forma- tion of odd magic squares. To form an odd magic square of the order n by this method, we begin by constructing two subsidiary squares, one of the unit-digits, 1, 2, . . . , n, and the other of multiples of the radix, namely, 0, n,2n, . . . ,(n − 1)n. We then form the magic square by adding together the numbers in the corresponding cells in the two subsidiary squares. De la Hire gave several ways of constructing such subsidiary squares. I select the following method (props. x and xiv of his memoir) as being the simplest, but I shall apply it to form a square of only the fifth order. It leads to the same results as the second of the two rules given by Moschopulus. The first of the subsidiary squares (figure vi, below), is constructed thus. First, 3 is put in the top left-hand corner, and then the numbers 1, 2, 4, 5 are written in the other cells of the top line (in any order). Next, the number in each cell of the top line is repeated in all the cells 3 4 1 5 2 2 3 4 1 5 5 2 3 4 1 1 5 2 3 4 4 1 5 2 3 First Subsidiary Square Figure vi. 15 0 20 5 10 0 20 5 10 15 20 5 10 15 0 5 10 15 0 20 10 15 0 20 5 Second Subsidiary Square Figure vii. 18 4 21 10 12 2 23 9 11 20 25 7 13 19 1 6 15 17 3 24 14 16 5 22 8 Resulting Magic Square Figure viii. which lie in a diagonal line sloping downwards to the right (see figure vi) according to the rule (ii) in De la Loubère’s method. The cells filled by * Mémoires de l’Académie des Sciencesfor 1705, parti, pp. 127–171.

PG26839.B00144
[PDF page 143] CH. V] MAGIC SQUARES OF AN ODD ORDER.. 127 the same number form abroken diagonal. It follows that every row and every column contains one and only one1, one and only one2, and so on. Hence the sum of the numbers in every row and in every column is equal to 15; also, since we placed3, which is the average of these numbers, in the top left-hand corner, the sum of the numbers in the left diagonal is15; and, since the right diagonal contains one and only one of each of the numbers1, 2, 3, 4, and 5, the sum of the numbers in that diagonal also is 15. The second of the subsidiary squares (figure vii) is constructed in a similar way with the numbers0, 5, 10, 15, and 20, except that the mean number10 is placed in the top right-hand corner; and the broken diagonals formed of the same numbers all slope downwards to the left. It follows that every row and every column in figure vii contains one and only one0, one and only one5, and so on; hence the sum of the numbers in every row and every column is equal to50. Also the sum of the numbers in each diagonal is equal to50. If now we add together the numbers in the corresponding cells of these two squares, we shall obtain25 numbers such that the sum of the numbers in every row, every column, and each diagonal is equal to 15 + 50, that is, to 65. This is represented in figure viii. Moreover, no two cells in that figure contain the same number. For instance, the numbers 21 to 25 can occur only in those five cells which in figure vii are occupied by the number20, but the corresponding cells in figure vi contain respectively the numbers1, 2, 3, 4, and5; and thus in figure viii each of the numbers from21to 25occurs once and only once. De la Hire preferred to have the cells in the subsidiary squares which are filled by the same number connected by a knight’s move and not by a bishop’s move; and usually his rule is enunciated in that form. By permuting the numbers1, 2, 4, 5 in figure vi we get4! other ar- rangements, each of which combined with that in figure vii would give a magic square. Similarly by permuting the numbers0, 5, 15, 20 in figure vii we obtain4! other squares, each of which might be combined with any of the4! arrangements deduced from figure vi. Hence alto- gether we can obtain in this way576 magic squares of the fifth order. There is yet another method of constructing odd squares which is due to Poignard, and was improved by De la Hire in the memoir already cited. I shall not discuss it, because, though for certain assigned values of n it is simpler than the methods which I have given, it depends on

PG26839.B00145
[PDF page 144] 128 MAGIC SQUARES. [CH. V the form ofn, and particularly on the number of prime factors ofn. In the case of a square of the fifth order, this gives an even larger number of magic squares than the methods of De la Loubère, Bachet, and De la Hire. I may also add that it has been shown that magic squares whose order is a prime number can be constructed by a rule similar to De la Loubère’s, except that we begin by placing1 in the bottom left-hand cell, and the subsequent consecutive numbers fill cells forming a knight’s path on the square and not a bishop’s path. A square of the fifth order of this kind is given in figure xiii on page 136. There are 2880 magic squares of the fifth order of this kind. De la Hire showed that, apart from mere inversions, there were 57600 magic squares of the fifth order which could be formed by the methods he enumerated. Taking account of other methods, it would seem that the total number of magic squares of the fifth order is very large, perhaps exceeding 500000. Magic squares of an even order. The above methods are inapplicable to squares of an even order. I proceed to give two methods for constructing anyeven magic squareof an order higher than two. It will be convenient to use the following terms. Two rows which are equidistant, the one from the top, the other from the bottom, are said to becomplementary. Two columns which are equidistant, the one from the left-hand side, the other from the right-hand side, are said to be complementary. Two cells in the same row, but in complementary columns, are said to be horizontally related. Two cells in the same column, but in complementary rows, are said to bevertically related. Two cells in complementary rows and columns are said to beskewly related; thus, if the cellb is horizontally related to the cella, and the cell d is vertically related to the cella, then the cellsb and d are skewly related; in such a case if the cellc is vertically related to the cellb, it will be horizontally related to the celld, and the cells a and c are skewly related: the cellsa, b, c, d constitute anassociated group, and if the square is divided into four equal quarters, one cell of an associated group is in each quarter. Ahorizontal interchangeconsists in the interchange of the numbers in two horizontally related cells. A vertical interchange consists in the interchange of the numbers in two vertically related cells. Askew interchange consists in the interchange of the numbers in two skewly related cells. Across interchangeconsists in the change of the numbers

PG26839.B00146
[PDF page 145] CH. V] MAGIC SQUARES OF AN EVEN ORDER.. 129 in any cell and in its horizontally related cell with the numbers in the cells skewly related to them; hence, it is equivalent to two vertical interchanges and two horizontal interchanges. First Method*. This method is the simplest with which I am ac- quainted, and I believe, at any rate as far as concerns singly-even squares, was published for the first time in 1893. Begin by filling the cells of the square with the numbers1, 2, . . . , n2 in their natural order commencing (say) with the top left-hand corner, writing the numbers in each row from left to right, and taking the rows in succession from the top. I will commence by proving that a certain number of horizontal and vertical interchanges in such a square must make it magic, and will then give a rule by which the cells whose numbers are to be interchanged can be at once picked out. First, we may notice that the sum of the numbers in each diagonal is equal toN, where N = 1 2 n(n2 + 1); hence the diagonals are already magic, and will remain so if the numbers therein are not altered. Next, consider the rows. The sum of the numbers in the xth row from the top isN − 1 2 n2(n − 2x + 1). The sum of the numbers in the complementary row, that is, thexth row from the bottom, is N + 1 2 n2(n − 2x + 1). Also the number in any cell in thexth row is less than the number in the cell vertically related to it byn(n − 2x + 1). Hence, if in these two rows we make1 2 n interchanges of the numbers which are situated in vertically related cells, then we increase the sum of the numbers in thexth row by 1 2 n × n(n − 2x + 1), and therefore make that row magic; while we decrease the sum of the numbers in the complementary row by the same number, and therefore make that row magic. Hence, if in every pair of complementary rows we make 1 2 n interchanges of the numbers situated in vertically related cells, the square will be made magic in rows. But, in order that the diagonals may remain magic, either we must leave both the diagonal numbers in any row unaltered, or we must change both of them with those in the cells vertically related to them. The square is now magic in diagonals and in rows, and it remains to make it magic in columns. Taking the original arrangement of the numbers (in their natural order) we might have made the square magic in columns in a similar way to that in which we made it magic in rows. * See an article in the Messenger of Mathematics, Cambridge, September, 1893, vol. xxiii, pp. 65–69.
