You are on page 1of 7

6?

It is obvious that such a problem is likely


Making magic squares of
to come after every 5 numbers.
Odd size
– Building a logic
16 9 2 25 18
Let us try to make a magic square of size 17 15 8 1 24 17
5x5. It will obviously contain numbers from 1
23 16 14 7 5 23
to 25. We can also call it a magic square of
order 5. To make such a square, consider
4 22 20 13 6 4
the magic square as a tile in a mosaic as 10 3 21 19 12 10
shown below. Let us start writing numbers
9 2 25 18 11
starting from 1 in the middle column of first
row and then diagonally moving towards
northwest i.e. 1 in Cell (1,3) i.e. third column
Let us continue in a similar pattern following
of first row. This way, we have to write 2 in
the earlier rule and write this to the south of
the Cell (0,2) and considering the magic
Cell (4,5) containing 10 i.e, in Cell (5,5).
square as a tile in mosaic, this is equivalent
Now, we can continue to northwest till we
to writing it in Cell (5,2). Moving northwest,
reach 15, which falls in Cell (1,1). Then 16
3 will obviously fall in Cell (4,1) and 4 can
should fall in Cell (0,0), but considering the
be written only in Cell (3,0) i.e. Cell (3,5) –
square to be mosaic this is equivalent to
as we consider the square as a tile in
Cell (5,5), hence we again move to south
mosaic. The number 5 will then follow in
i.e. Cell (2,1). Continue to in similar pattern
Cell (2,4).
17 comes in Cell (1,0) i.e. Cell (1,5), then 18
in Cell (0,4) i.e. Cell (5,4), 19 in Cell (4,3)
This will, however, create a problem as 6
and 20 in Cell (3,2). Again move south (note
falls in Cell (1,3), but the latter is already
Cell (2,1) is already occupied by 16) and 21
occupied by 1. So, where we do write 6? Let
comes in Cell (4,2), 22 in Cell (3,1), 23 in
us move it to the south of Cell (2,4)
Cell (2,5) equivalent of Cell (2,0), 24 in Cell
containing 5 i.e. in Cell (3,4). Now we can
(1,4) and finally 25 in Cell (5,3) which is
continue in similar way and write 7 in Cell
equivalent to Cell (0,3) northwest. One can
(2,3), 8 in Cell (1,2) and then 9 falls in Cell
easily check that all the rows and columns
(0,1), which is equivalent to Cell (5,1) and
as well as diagonals all add up to 65 which
then 10 goes in Cell (4,5) as it is equivalent
is nothing but the number 0.5*n*(n2+1),
to Cell (4,0). Where do we write 11, as
where n is the size of the square.
northwest Cell (3,4) is already occupied by
observation is that numbers in each series
One can similarly make a magic square of
(of 1 to n, n+1 to 2n and so on) fall in
order 7, starting again from 1 in the centre
different rows and columns. ♣
of first row and then following similar logic.
The only difference is that in place of after A few questions more – (i) why we are
every set of five numbers we have to move starting only from 1 in the centre of first row;
south after every seven numbers. The (ii) why do we move only to northwest in
magic square then looks like one given each series of 5 or 7 numbers and (iii) why
below. we move only to the south after each series
of 5 or 7 is completed.
28 19 10 1 48 39 30
29 27 18 9 7 47 38 In fact, as may be seen from following
square (shown on the next page), where for
37 35 26 17 8 6 46 a square of size 7x7, we start from 1 in Cell
45 36 34 25 16 14 5 (4,5) and move northeast (within each
4 44 42 33 24 15 13 series of seven numbers) and then move
two steps to the east, whenever we face a
12 3 43 41 32 23 21 problem at the end of each series of seven.
20 11 2 49 40 31 22
Again total of each row, column and
4 29 12 37 20 45 28
diagonal is 175. In a similar way, any magic 35 11 36 19 44 27 3
square of odd order, say 9, can be made.
One caneven try for a magic square of order
10 42 18 43 26 2 34
99 or may be higher. 41 17 49 25 1 33 9
It may also be observed that in the magic 16 48 24 7 32 8 40
square of order 5, the middle number 13 47 23 6 31 14 39 15
was in the centre of the square. Similarly, in
the magic square of order 7, the middle
22 5 30 13 38 21 46
number of the series, which is 25, is in the
centre of the square. It is simple to workout
that the number in the centre of a magic

square of order 9 will be 41 and number in It is based on observation as well as the fact
that whenever this is not so, magic square does
the square of order 99 will be 4901. Another not work out and sums of some rows, columns
or diagonal may not work out properly.
It can be easily checked that the total of would like to have 1 to n and hence we
each row, column and diagonal is again consider n in place of 0. For example, in
175. Further, the middle number 25 is considering magic squares, say of order 7
appearing in the centre of the square. We (i.e. size 7x7), we restrict ourselves to
can similarly try making a square of order 5. numbers from 1 to 7. On this scale, while 0
This should look like the following. = 7, 12 = 5 and -1 = 6.

One change, in the development of logic for


3 16 9 22 5 the purpose we make, is that in place of

20 8 21 14 2 using matrix form (of numbering a cell in


terms of the number of row and column), we
7 25 13 1 19 number a cell like one describes location of

24 12 5 18 6 points in coordinate geometry considering


the square as a tile in the first quadrant i.e.
11 4 17 10 23 the left hand bottom cell is numbered as
Cell (1,1). Thus the cell containing 1 in the
Could we work upon this to build up logic for above magic square is now described as
making magic squares of odd order? Cell (5,4) and not in Cell (4, 5). Similarly 3 is
now in Cell (7,6) and not Cell (2,7).
Let us try to build the same on whatever we
have done till now, but before that let us first Let (x, y) represent the position of 1 inn a
try to use a little algebra in place of square of order n. For 2, we move ‘p’
numbers. As for building the magic square squares to the east (i.e. +p as in coordinate
we consider it as a tile in mosaic, we will geometry) and ‘q’ squares to the north (i.e.
use modular arithmetic. Modular of any +q in coordinate geometry). Hence, 2 will lie
number to a given base is obtained by in cell (x+p, y+q). Naturally, the position nth
dividing this number by base and remainder number in a square of order n will be (modn
thus obtained is the modulus of the number (x+np), modn (x+nq)).
with the given base. For example, mod5 17
= mod5 42 = 2, where 5 is the base. (Thus, Here we make another change in the

if mod of two numbers is equal, then the notation and the position of next series of

difference between the two numbers will be numbers starting from (n+1) may be defined

a multiple of the base. Obviously mod value relative to first number in the series 1 to n

of a number to base n, will be numbers from and not n (i.e. 7 as given in above

0 to (n-1). However, for magic squares we example). So position of the starting point of
the next series of n numbers (i.e. n+1 to 2n) x p a
Thirdly, ≠ ≠ .
is defined in relation to starting point of y q b
previous series (i.e. 1 to n) and let the Lastly, to ensure that each number of the
position of n+1 be ‘a’ squares to the west series (1 to (2n+1), (2n+2) to (4n+2) and so
and ‘b’ squares to the south of 1. In a magic on) lies in a different row and column, a, b,
square of order 7, the position of 25 will p or q should not be a factor of (2n+1). This
then be given by (mod7 (x-3a+3p), mod7 (y- was not in above examples, as 5 and 7
3b+3q)). For 25 to be in the centre of the were prime numbers, but for a square of
square each of mod7 (x-3a+3p) and mod7 order 9, 15, 21 or 25, this could be
(y-3b+3q) should be equal to 4. important.

We make another change here and as we Let us consider the first magic square of
are considering magic squares of odd order, order 5 (on page 1). In this (x, y) is (3, 5),
in place of n, let us now talk of a square of (p, q) is (4, 1) and (a, b) is (4, 2). Let us
order (2n+1). One can easily work out that assume, we have just (x, y) as (3, 5) and (p,
in such a magic square, sum of each row, q) as (4, 1). As n=2, this gives us the
column and diagonal should be equations mod5 (3-2a+8) = mod5 (5-2b+2) =
2
(2n+1)(2n +2n+1). Further, position of the 3 or mod5 (11-2a) = mod9 (7-2b) = 3.
middle number in a square of order (2n+1) Solving 11-2a = 7-2b gives us a=b+2 and
will be given by solutions for (a, b) thus could be (3, 1),
(mod2n+1 (x-na+np), mod2n+1 (y-nb+nq)) (4, 2), (5, 3), (6, 4) or (7, 5). As may be seen
and each of only (a, b) as (4, 2) satisfies the condition
mod2n+1 (x-na+np) and mod2n+1 (y-nb+nq) mod5 (3-2a+8) = mod5 (5-2b+2) = 3 and
should be equal to n+1. hence the solution.

Further, there will have to be some Alternatively, assume we have (x, y) as (3,
limitations on the values of p, q, a and b. 5) and (a, b) as (4, 2). The equations now
First of all, they can be only 1 to 2n (not are mod5 (3-8+2p) = mod5 (5-4+2q) = 3 or
2n+1). Similarly x and y cannot be together mod5 (-5+2p) = mod9 (1+2q) = 5. Solving
(n+1). -5+2p = 1+2q gives us p=q+3 and solutions
for (p, q) thus could be (4, 1), (5, 2), (6, 3),
Secondly, they should satisfy the condition
(7, 4) or (8, 5) and as can be seen only for
that mod2n+1 (x-na+np) = mod2n+1 (y-nb+nq)
(p, q) as (4, 1) each of mod5 (-5+2p) and
= (n+1). ……… (1)
mod9 (1+2q) could be 3.
One can similarly try for squares of order 7 numbers 1, 10, 19, 28, … … in same row
on page 2. While in the first square (x, y) is and hence magic square, with 1 starting
(4, 7), (p, q) is (6, 1) and (a, b) is (6, 2), in from (1,1) and next number i.e. 2 moving
second square we find (x, y) is (5, 4), (p, q) two cells to east and four cells to north i.e.
is (1, 1) and (a, b) is (6, 1). (p, q) as (2, 4), cannot be formed. However,
if we try with (a, b) as (7, 9), we will get a
In the first case, equations are
square, where columns and diagonals will
mod7 (4-3a+3p) = mod7 (7-3b+3q) = 4, while
add up to 369, but not rows as can be seen
in second case they are
from the following.
mod7 (5-3a+3p) = mod7 (4-3a+3p) = 4

15 60 24 69 33 78 42 6 51
One can easily see that in each of these
three cases solution is possible as these
80 44 8 53 17 62 26 71 35

numbers (a, b, p and q) are co-prime 55 19 64 28 73 37 1 46 10


relative to 5 or 7, the order of the magic 39 3 48 12 57 21 66 30 75
square. However, when it is not so, we do
23 68 32 77 41 5 50 14 59
get a problem. Let us consider a magic
7 52 16 61 25 70 34 79 43
square of order 9 (i.e. n=4), in which we
start from cell (7, 7) i.e. we have 1 in this 72 36 81 45 9 54 18 63 27
cell and x=7 and y=7. For 2, let us move two 47 11 56 20 65 29 74 38 2
cells to east and four cells to north i.e. p=2 31 76 40 4 49 13 58 22 67
and q=4. It is apparent that equation (1)
above becomes
It is apparent that while ensuring the middle
mod9 (15-4a) = mod9 (23-4b) = 5.
number 2n2+2n+1 in a square of order
(2n+1) results in diagonals of square to add
This means the difference between (15-4a)
up to 2(2n+1)(2n2+2n+1) – here 369, if p is
and (23-4b) should 0 or a multiple of 9 and
not a factor of (2n+1), columns will add up
further each of mod9 (15-4a) and mod9 (23-
to 2(2n+1)(2n2+2n+1) and if q is not a factor
4b) should be equal to 5. (15-4a) = (23-4b)
of (2n+1), rows will add up to
gives us b=a+2. One can easily try various
2(2n+1)(2n2+2n+1).
combinations of (a,b) such as (1,3), (2,4)
and so on. It can be easily established that
Let us also try (23-4b)-(15-4a) or (8-4b+4a)
only solution possible is (7,9), which gives
as a multiple of 9. It is apparent that as we
each of mod9 (15-4a) and mod9 (23-4b) as
are dealing with whole numbers only we can
5. However, as b is 9, this will bring all
only choose their difference as 36 i.e.
a=7+b or b-a= -7. With base as 9, is it not the following magic square. As a, b, p and q
similar to b=a+2? One can try and will again are co-prime to 9, we get a magic square in
get that only for (a, b) as (7, 9), such a which rows, columns and diagonals all add
solution is possible, but as b=9, no magic up to 369.
square is possible.
37 48 59 70 81 2 13 24 35
Let us try making a magic square starting
36 38 49 60 71 73 3 14 25
from 1 in (7, 3), with (p, q) as (2, 7). The
26 28 39 50 61 72 74 4 15
equation now becomes mod9 (14-4a) = 5
and mod9 (30-4b) = 5. (14-4a) = (30-4b) 16 27 29 40 51 62 64 75 5
gives b = a+4. This has a solution (9, 13) or 6 17 19 30 41 52 63 65 76
(9, 4). As a=9 has common factor with 9, 77 7 18 20 31 42 53 55 66
forming magic square with (x, y) as (7, 3),
67 78 8 10 21 32 43 54 56
(p, q) as (2, 7) and (a, b) as (9, 4) leads to
57 68 79 9 11 22 33 44 46
columns not adding to 369, while rows and
diagonals will add up to 369 as the series 1, 47 58 69 80 1 12 23 34 45
10, 19, 28 … … in row in the same column.
Similarly one can make a magic square of
39 62 76 18 32 46 69 2 25 order 9 with (x, y) as (5, 4), (p, q) as (1, 8)
21 44 58 81 14 28 51 65 7 and (a, b) as (1, 1). Here too all are co-

3 26 40 63 77 10 33 47 70 prime to 9 and we do get the following


magic square.
66 8 22 45 59 73 15 29 52
48 71 4 27 41 55 78 11 34 37 78 29 70 21 62 13 54 5
30 53 67 9 23 37 60 74 16 6 38 79 30 71 22 63 14 46
12 35 49 72 5 19 42 56 79 47 7 39 80 31 72 23 55 15
75 17 31 54 68 1 24 38 61 16 48 8 40 81 32 64 27 56
57 80 13 36 50 64 6 20 43 57 17 49 9 41 73 33 65 25
26 58 18 50 1 42 74 34 66
However, with (x, y) as (5, 1) and (p, q) as
67 27 59 10 51 2 43 75 35
(1, 8), we get equations mod9 (5 - 4a + 4) =
36 68 19 60 11 52 3 44 76
mod9 (1 - 4b + 32) = 5 i.e. mod9 (9 - 4a) =
mod9 (33 - 4b) = 5 and we can similarly find 77 28 69 20 61 12 53 4 45
a solution to this in (a, b) = (1, 7) resulting in
Trials will show that making such a square start filling up first 9 numbers in the bottom
is not easy and we do run into problems. central square. After completing this to write
Let us now try (x, y) as (4, 7) and (p, q) as numbers from 10 to 18, we can move to top
(2, 2) and we get our equations as right sub-square, for 19 to 27 to central left
mod9 (12 - 4a) = 5 and mod9 (15 - 4b) = 5. square and so on, arranging them according
As (12 - 4a) = (15 - 4b) i.e. 4(b-a) = 3 does to numbers in the magic square of order 3.
not give us whole numbers as solution, let This way, one gets the following magic
us choose (12 – 4a) – (15 – 4b) = 9, to square In the above example.
satisfy the equation mod9 (12 - 4a) = mod9
(15 - 4b). This gives b = a + 3 and as can be 31 36 29 76 81 74 13 18 11
easily seen (4, 7) gives mod9 (12 - 4a) = 30 32 34 75 77 79 12 14 16
mod9 (15 - 4b) = 5. However, if one tries 35 28 33 80 73 78 17 10 15
x a
one will run into problem as = . 22 27 20 40 45 38 58 63 56
y b
21 23 25 39 41 43 57 59 61

It may appear from above that there are 26 19 24 44 37 42 62 55 60


limitations in making squares of odd order, if 67 72 65 4 9 2 49 54 47
the order is a composite number. However, 66 68 70 3 5 7 48 50 52
there are other ways of making magic
71 64 69 8 1 6 53 46 51
squares in such cases. One may note that 9
is given by 3× 3 . Hence, we may consider
For a magic square of order 15, one may
the square of order 9 as nine magic squares
choose 3x5 or 5x3. In a similar way any
of order 3 in a square of order 9. For this let
magic square of order n1 × n 2 can be
us consider the following magic square of
constructed based on two magic squares of
order 3 (something like in the popular game
order n1 and n2 and one can have either n22
sudoku).
squares each of size n12 or n12 squares

4 9 2 each of size n22.


- Shwetank Mauria
3 5 7
smauria55@gmail.com
8 1 6 * * *

Now we can consider a square of order 9,


divided in 9 squares of order 3 (let us call The above document is based on a paper written by
the author in 1974.
each of these squares as sub-square) and

You might also like