## 7x7 magic square

### 7x7 magic square

Just for fun, I made a magic square:

$\begin{bmatrix} 8 & 16 & 24 & 32 & 40 & 48 & 56 \\ 31 & 39 & 47 & 55 & 14 & 15 & 23 \\ 54 & 13 & 21 & 22 & 30 & 38 & 46 \\ 28 & 29 & 37 & 45 & 53 & 12 & 20 \\ 44 & 52 & 11 & 19 & 27 & 35 & 36 \\ 18 & 26 & 34 & 42 & 43 & 51 & 10 \\ 41 & 49 & 50 & 9 & 17 & 25 & 33 \end{bmatrix}$

The sum of all the rows, columns, and diagonals is 224.

If anyone is interested, I can explain how to make a $p \cdot p$ magic square for any prime $p \geq 7$.
icemanfan

Posts: 614
Joined: Sun Feb 26, 2012 4:19 pm

### Re: 7x7 magic square

It kind of reminds me of soduko.
How did you do it?
JohnLock
Newcomer

Posts: 5
Joined: Thu Mar 29, 2012 1:35 am

### Re: 7x7 magic square

Here is another . . .

. . $\begin{array}{ccccccc} 38 & 23 & 8 & 49 & 34 & 19 & 4 \\ \\ \\
30 & 15 & 7 & 41 & 26 & 11 & 45 \\ \\ \\
22 & 14 & 48 & 33 & 18 & 3 & 37 \\ \\ \\
21 & 6 & 40 & 25 & 10 & 44 & 29 \\ \\ \\
13 & 47 & 32 & 17 & 2 & 36 & 28 \\ \\ \\
5 & 39 & 24 & 9 & 43 & 35 & 20 \\ \\ \\
46 & 31 & 16 & 1 & 42 & 27 & 12 \end{array}{$

The magic sum is 175.

soroban
Super User

Posts: 2309
Joined: Sun Dec 10, 2006 9:37 am
Location: Lexington, MA

### Re: 7x7 magic square

JohnLock wrote:It kind of reminds me of soduko.
How did you do it?

Make an n by n Latin square A as follows:

Start with the top row, which will be all of the numbers 1 to n in order. Now the row below will be the same numbers shifted two places to the right (you can shift any number which is relatively prime to n), and each successive row you will apply the same shift to the previous row. Here is the example for n = 5:

$\begin{bmatrix} 1 & 2 & 3 & 4 & 5 \\ 4 & 5 & 1 & 2 & 3 \\ 2 & 3 & 4 & 5 & 1 \\ 5 & 1 & 2 & 3 & 4 \\ 3 & 4 & 5 & 1 & 2 \end{bmatrix}$

Now make another Latin square B in the same way, except shifting by a different amount (3 instead of 2, for example):

$\begin{bmatrix} 1 & 2 & 3 & 4 & 5 \\ 3 & 4 & 5 & 1 & 2 \\ 5 & 1 & 2 & 3 & 4 \\ 2 & 3 & 4 & 5 & 1 \\ 4 & 5 & 1 & 2 & 3 \end{bmatrix}$

Finally, to create the magic square C, each cell $c_{ij}$ will contain the number $n \cdot a_{ij} + b_{ij}$, where $k_{ij}$ represents the entry in the ith row and the jth column of square K.

This will work as long as both shifts are relatively prime to n (in the example 2 and 3 are both relatively prime to 5), and the difference between the shift numbers is relatively prime to n (in the example the difference is 1, which is relatively prime to 5).
icemanfan