If this information and this web page are useful to you, |
For this example, we will use 881 as our Magic Sum.
Step Two (the hardest step): As you pick your random numbers, watch out for duplicate numbers. While a square with duplicate numbers is still magic, most people prefer their magic squares to contain all different numbers. If you allow some numbers to be negative, you'll have more choices as you create your square. We will allow negative numbers for examples you see on this page (though they won't always appear, because every time you load this page, I'm generating new random numbers).
Step Three: Pick random numbers for three of the corners:
| 26 | 298 | ||
| 176 |
Step Four: Subtract the three corners from the Magic Sum to get the value for the fourth corner: 881 - 26 - 298 - 176 = 381
| 26 | 298 | ||
| 381 | 176 |
Step Five: Pick random numbers for the middle positions in the second row:
| 26 | 298 | ||
| 291 | 19 | ||
| 381 | 176 |
Step Six: Subtract the other three numbers from the Magic Sum to get the fourth number in each diagonal: (for example: 881 - 26 - 291 - 176 = 388 )
| 26 | 298 | ||
| 291 | 19 | ||
| 183 | 388 | ||
| 381 | 176 |
Alternate Six: You might find it easier to subtract the inner number in one diagonal from the sum of the two corners on the other diagonal. (For example, 26+176=202. Subtract 19 from that sum to get the other number for one inner diagonal, then do the same thing for the other inner diagonal.
Step Seven: Put a random number into the bottom box in the second column
| 26 | 298 | ||
| 291 | 19 | ||
| 183 | 388 | ||
| 381 | 402 | 176 |
Step Eight: In any row or column that has three numbers already, calculate the fourth number by subtracting the three numbers from the Magic Sum: (for example: 881 - 291 - 183 - 402 = 5 )
| 26 | 5 | 552 | 298 |
| 291 | 19 | ||
| 183 | 388 | ||
| 381 | 402 | -78 | 176 |
Alternate Eight: You might find it easier to observe that the sum of the middle two squares in the top row must add up to the sum of the outer squares in the bottom row, and vice-versa. In other words, add the top two corners, then subtract the number you just put into the square in step 7 to get the other number for the bottom row. You can use the same trick to find your next two numbers. The sum of the top and bottom numbers in the second column must be equal to the sum of the inner two numbers in the third column, and vice-versa.
Step Nine: Put a random number into the last box in the second row:
| 26 | 5 | 552 | 298 |
| 291 | 19 | 392 | |
| 183 | 388 | ||
| 381 | 402 | -78 | 176 |
Step Ten: For any row or column missing a number, subtract the other three values from the Magic Sum to get the fourth value: (for example: 881 - 291 - 19 - 392 = 179 )
| 26 | 5 | 552 | 298 |
| 179 | 291 | 19 | 392 |
| 295 | 183 | 388 | 15 |
| 381 | 402 | -78 | 176 |
Alternate Ten: The same trick given in Alternate Eight applies here. If you look at just the two diagonals, or just the two outer rows, or just the two outer columns, or just the two inner rows, or just the two inner columns, the two inner numbers in one set of four numbers must add up to the sum of the outer numbers in the other set of four numbers. So, practice these alternate directions and you'll find it a lot easier to amaze your friends by creating magic squares at parties, as a kind of magic trick.
Step Eleven: Check for duplicate numbers. If you see a duplicate in the group of numbers you added in steps 9 and 10, you might be able to add 1 to two sort-of-opposite-numbers and subtract 1 from the other two to eliminate the duplicate. Just experiment to eliminate your duplicates. If you use the spreadsheet program below, and only change squares that contain numbers, you should find it very easy to experiment with a variety of magic squares.
Would you like to make another magic square? Just click REFRESH.
Would you like to make a magic square with a specific sum? The easiest way to get a specific sum is to use the form at the top of this page, but if you wish, you may use this URL instead. Just change the number to your desired magic sum:
http://www.mazes.com/magic-squares/4x4-rnd.asp?magicsum=34
If your web browser does not allow you to use this Interactive Magic Square Spreadsheet, put these values and formulas into your spreadsheet program:
| Column A | Column B | Column C | Column D | Column E | Column F | Column G | |||
| Row 1 | 0 | =A8-B2-B3-B4 | =A8-A1-B1-D1 | 3 | =SUM(A1:D1) | =D1+C2+B3+A4 | |||
| Row 2 | =A8-B2-C2-D2 | 5 | 6 | 8 | =SUM(A2:D2) | ||||
| Row 3 | =A8-B3-C3-D3 | =A8-D1-C2-A4 | =A8-A1-B2-D4 | =A8-D1-D2-D4 | =SUM(A3:D3) | ||||
| Row 4 | 12 | 2 | =A8-A4-B4-D4 | =A8-A1-D1-A4 | =SUM(A4:D4) | =A1+B2+C3+D4 | |||
| Row 5 | |||||||||
| Row 6 | =SUM(A1:A4) | =SUM(B1:B4) | =SUM(C1:C4) | =SUM(D1:D4) | |||||
| Row 7 | |||||||||
| Row 8 | 34 | Sum | =IF((A6=A8)*(B6=A8)*(C6=A8)*(D6=A8)*(F1=A8)*(F2=A8)*(F3=A8)*(F4=A8)*(G1=A8)*(G4=A8),"Magic Square","ERROR!!!") | ||||||
David Hrbacek and Arleen Knoderer
P O Box 235
Sulphur Springs, AR 72768-0235