## 5x5 and other odd-numbered Magic Squares

Suzanne's Magic Squares || Multiplying Magic Squares: Contents || Exploring the Math

To construct 5x5 and other odd-numbered magic squares, let us look at de la Loubère's method. Basically, one uses doughnuts to make the magic square.

Start with an empty n x n square, where n is odd. We'll begin with n = 5 and denote its blank entries with dots.
```
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .

```
The problem of making this into a magic square is one of counting from 1 to 25 (in general n^2) as one runs through the boxes of the square in some order. The basic rule for doing this is that one counts diagonally upwards to the right. For example, if one has written a 12 in the 2nd position of the 4th row
```
.  .  .  .  .
.  .  .  .  .
.  .  .  .  .
. 12  .  .  .
.  .  .  .  .

```
then the numbers 13,14,15 will be placed thus:
```
.  .  .  . 15
.  .  . 14  .
.  . 13  .  .
. 12  .  .  .
.  .  .  .  .

```
Let's see this in action.

First I have to tell you where to start: begin in the middle of the top row with a 1. (Here is where we use the assumption that n is odd, which guarantees that there is a middle square in the top row).
```
. . 1 . .
. . . . .
. . . . .
. . . . .
. . . . .

```
Now, the first thing one observes is that it is impossible to move diagonally upwards from this position, since we are already at the top of the square. This is an example of what can go wrong with the basic method of moving diagonally upwards to the right. There are actually three things that can go wrong:
1. You could be at the top edge of the square so you can't go up.
2. You could be at the right edge of the square so you can't move right.
3. The square you would like to put the next number in may already be occupied.

Here is what to do in those cases:
1. If you are at the top edge, pretend that the top edge is pasted to the bottom edge and come up through the bottom. Thus, after 1, we place 2 as follows:
```
.  .  1  .  .
.  .  .  .  .
.  .  .  .  .
.  .  .  .  .
.  .  .  2  .

```
In other words, we pretend that the bottom row is the row above the top row. Moving diagonally upwards to the right means moving up one row and over one column to the right. So the 2 goes in the bottom row one column to the right of the column containing the 1.

2. If you are at the right edge, pretend that the right edge is pasted to the left edge and that the left edge is immediately to the right of the right edge. We are in this situation after counting to 3, since after the above diagram, we have
```
.  .  1  .  .
.  .  .  .  .
.  .  .  .  .
.  .  .  .  3
.  .  .  2  .

```
and apparently have no place to go. But moving diagonally upwards to the right is the same as moving right one column and up one row. Moving right one column from the rightmost column puts us in the leftmost column, so 4 must be in the leftmost column, and moving up one row we put the 4 in the row above the row containing the 3. So we get
```
.  .  1  .  .
.  .  .  .  .
4  .  .  .  .
.  .  .  .  3
.  .  .  2  .
```
3. What if there is a number already occupying the square one would like to move into? We are in this situation after we place the number 5. Indeed, continuing from the previous diagram, we place the 5 diagonally upwards and to the right of the 4 and get
```
.  .  1  .  .
.  5  .  .  .
4  .  .  .  .
.  .  .  .  3
.  .  .  2  .

```
and when we next try to place the 6, the square we would like to put the 6 in already has the 1 in it! When this happens, the rule is to abandon, just this once, the plan of moving diagonally upwards to the right and instead just drop down one square from the square one is in presently. So the 6 will be placed directly below the 5.
```
.  .  1  .  .
.  5  .  .  .
4  6  .  .  .
.  .  .  .  3
.  .  .  2  .

```
After that, one continues counting normally:
```
.  .  1  8  .
.  5  7  .  .
4  6  .  .  .
.  .  .  .  3
.  .  .  2  .

```
Eventually, one gets the whole 5x5 square in this way:
```
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

```
The application of the basic rule of counting diagonally upwards, with the modifications above for handling the edges and the case where a number is in the way, is pretty straightforward. But there is one case that requires a little thought. Namely, when one gets to 15, where does one go next?
```
.  .  1  8 15
.  5  7 14  .
4  6 13  .  .
10 12  .  .  3
11  .  .  2  9

```
Since 15 is in the top row, 16 would normally go in the bottom row. Since 15 is on the right edge, 16 would normally go on the left edge. The position which is in the bottom row and the left edge is the lower left corner. That is where we want to put the 16. Unfortunately, it is already occupied by the number 11. So there is a number in the way, and the rule is then to drop down to the square below the 15. That is why the 16 is directly below the 15.
```
.  .  1  8 15
.  5  7 14 16
4  6 13  .  .
10 12  .  .  3
11  .  .  2  9

```
All other instances of the rules are a lot easier to figure out.

The same method was used to make a 3x3 magic square:
```
8 1 6
3 5 7
4 9 2

```
and the same method can be used to make a 7x7 magic square:
```
30 39 48  1 10 19 28
38 47  7  9 18 27 29
46  6  8 17 26 35 37
5 14 16 25 34 36 45
13 15 24 33 42 44  4
21 23 32 41 43  3 12
22 31 40 49  2 11 20

```
or a 17x17 magic square:
```155 174 193 212 231 250 269 288   1  20  39  58  77  96 115 134 153
173 192 211 230 249 268 287  17  19  38  57  76  95 114 133 152 154
191 210 229 248 267 286  16  18  37  56  75  94 113 132 151 170 172
209 228 247 266 285  15  34  36  55  74  93 112 131 150 169 171 190
227 246 265 284  14  33  35  54  73  92 111 130 149 168 187 189 208
245 264 283  13  32  51  53  72  91 110 129 148 167 186 188 207 226
263 282  12  31  50  52  71  90 109 128 147 166 185 204 206 225 244
281  11  30  49  68  70  89 108 127 146 165 184 203 205 224 243 262
10  29  48  67  69  88 107 126 145 164 183 202 221 223 242 261 280
28  47  66  85  87 106 125 144 163 182 201 220 222 241 260 279   9
46  65  84  86 105 124 143 162 181 200 219 238 240 259 278   8  27
64  83 102 104 123 142 161 180 199 218 237 239 258 277   7  26  45
82 101 103 122 141 160 179 198 217 236 255 257 276   6  25  44  63
100 119 121 140 159 178 197 216 235 254 256 275   5  24  43  62  81
118 120 139 158 177 196 215 234 253 272 274   4  23  42  61  80  99
136 138 157 176 195 214 233 252 271 273   3  22  41  60  79  98 117
137 156 175 194 213 232 251 270 289   2  21  40  59  78  97 116 135

```
What does this have to do with doughnuts? A lot. For starters, and I'll go no further than that right now, notice what we did:
1. We took a square and pasted its top edge to its bottom edge, matching up each column to itself. That in effect made a cylinder.

2. Then we pasted the left edge to the right edge, matching up each row to itself. That in effect took the cylinder and pasted its two ends together to make a doughnut (except mathematicians like to sound more dignified by calling it a "torus").

Back to How to construct magic squares

[Privacy Policy] [Terms of Use]

© 1994- The Math Forum at NCTM. All rights reserved.
http://mathforum.org/

Web page design and graphics by Sarah Seastone