The Ecphorizer

Be A Math Whiz
Dave Kirby

issue #04 (December 1981)


When you construct a magic square, the numbers always add up


[quoteleft]Amaze your friends! Win free drinks! Be the life of the party! Wow, gang!! Seriously, all of the above can happen if you can steer the conversation around to the subject of magic squares, and, with superior smile, prove that you can manipulate

Amaze your friends! Win free drinks! Be the life of the party!

them with ease. If you work it right, you may even win some heavier bets by challenging your audience to compete with you in constructing a magic square or you could even score some heavy paints with a member (in good standing) of the opposite sex in return for the secret of how it's done.

By way of definition, a magic square is a grid of boxes, 5x5, 7x7, or whatever, filled with numbers in an arrangement such that each row, each column, and each diagonal adds up to the same sum. For example:

 

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 sum in any direction for this magic square is 65. This is a 5x5 magic square, but the method described here works for any odd number of rows and columns greater than 3, and for any sum you may choose. (Somewhere, I have a half-finished magic square of 127 rows and 127 columns--1/27 is my birthday-that adds up to exactly 1,000,000, which I was going to send to the Guinness people, the method works fine, but the actual construction got pretty tedious).

The first thing to do, after having one of your audience specify the total that your magic square is to add up to, is to find the starting number to put in the square (well, actually, the first thing to do is to draw the grid on a piece of paper, but if the party isn't too far along and you're relatively sober, you should be able to do all the following calculations flashingly within your nimble brain while you draw the thing). The starting number is found by the formula

SUM / N - X

where N is the number of boxes on a side of the square, and X is

(TOTAL BOXES - 1) / 2

So the starting number for the sample square above is

65 / 5 - ((25-1) / 2) = 1

If SUM/N gives a reminder, remember it; you'll need it later. Now its time to start filling in the square. The starting number always goes in the center box of the top row; thereafter, the entry sequence is as follows:

 

1,  From the last number entered, move diagonally one box up and one box to the right put the integer that is one greater than the last number entered in that box.
  • a. If the diagonal move would cause an entry outside and above the entire square, put the next number in the bottom box of the column you're above.
  • b. If the diagonal move would cause an entry outside and to the right of the entire square, pit the next number in the left most box of the r you're to the right of.
2.  If no entry is possible according to the above rules (you are diagonally above and to the right of the entire square, or the box you've arrived at already has an entry), put the next entry directly below the previous one.

If you did it right, the last entry, which is (TOTAL BOXES-1) greater than the starting number will go in the center box of the bottom row. Check the sample square above for the entry sequence.

Okay, now we come to special cases. What if (SUM/N) is less than X? Well, you're going to have one or more negative numbers in your magic square; nobody said you couldn't. Just remember that -10 is greater than -11, and so on, and just follow the entry sequence until you get to zero, then switch to positive numbers and keep going.

But what if (SUM/N) produces a remainder? Well, this is a little bit trickier, but no real problem. Each magic square has certain special boxes, special because they appear only once in any raw, column or diagonal. Using a 5x5 square as an example, those boxes are:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You can find those special boxes in a 7x7, 9x9, or whatever, square by starting in the upper left corner and going a "knight's move" to the right and down until you reach the right edge, then continuing to count as you "wrap around" to the left edge.

Remember I said to bold on to the reminder if there's one? Okay, now add the reminder to the numbers in those special boxes. You're going to have some duplication of numbers in this case; again, nobody said you couldn't.

You can go back after you've finished filling in the square and erase the numbers, add the reminder, and write the new numbers, but it's ever so much more impressive if you can do it on the fly, adding the remainder in your head and writing the correct number as you come to a special box (but don't forget to drop back to the original sequence before writing the next number).

Okay, you've got the mechanics, now go show 'em you're in the top 2%. There's just one more word to remember: SHOWMANSHIP. Have fun. 


Game-player and logophile Dave Kirby has held various elected positions within the SF Regional Mensa group. He lives with a dog named Rainbow, who does an unparalleled cat imitation whenever company is present.

More Articles by Dave Kirby



close
Title:
Link:
Summary:
We have collected the essential data you need to easily include this page on your blog. Just click and copy!close
E-mail Print to PDF Blog
Return to Table of Contents for issue #04