Magic Squares return to Netstaff top [ Japanese page ]

29/12/04 5x5 magic square program source is now available!! Please view description below.

Do you know Magic Squares?

For example, 4x4 magic square puts in the number of 1-16 into the grid of 4x4,
and the sum total of the numbers perpendicularly, horizontally, and diagonal located
in line is set to 34.

(The following figure shows an example of 4x4 magic square.)

Moreover, 5x5 magic square puts in the number of 1-25 into the grid of 5x5,
and the sum total of the numbers perpendicularly, horizontally, and diagonal located
in line is set to 65.

(The following figure shows an example of 5x5 magic square.)




Moreover, 6x6 magic square puts in the number of 1-36 into the grid of 6x6,
and the sum total of the numbers perpendicularly, horizontally, and diagonal located
in line is set to 111.

(The following figure shows an example of 6x6 magic square.)




Since the predecessors have explained how to make for the order of numbers in many WEB sites,
 no related theory is shown here.

The purpose of this page is to introduce some programs that number the total of 4x4 , 5x5 and 6x6 magic squares.

The total of magic squares is the number of the orders that satisfy the sum of 4 , 5 or 6 numbers located in line,
 but exclude what is made right and left reversed, upside down exchanged, or rotated 180 degrees.

<A program to number the total of 4x4 magic squares (Windows version)>
<The source code of program to number the total of 4x4 magic squares (Linux C language version)>  New!!

The total of the orders of 4x4 magic square is 880.

<A program to number the total of 5x5 magic squares (Windows version)>
<A program to number the total of 5x5 magic squares (Linux version)>
<The source code of above program  (C language version)> 

The total of 5x5 magic squares increases in number to 275,305,224 at a stretch.
Since it is a serious number, it takes time considerably also with the latest personal computer.
Then, although 4 numbers except the center on a diagonal line have 12 kinds of order in a line, it is enabled
 to calculate 1/4 of the total using a rule of what 12 kinds are made of 4 times of 3 basic orders.

Even if counting quarter of the total, it requires time too much.
Then, the above programs are enabled to count the total for each number of the center of 5x5 grid.

(center)  (sub total)  (quarter sub total)
  1       4,365,792      1,091,448
  2       5,464,716      1,366,179
  3       7,659,936      1,914,984
  4       7,835,348      1,958,837
  5       9,727,224      2,431,806
  6      10,403,516      2,600,879
  7      12,067,524      3,016,881
  8      12,448,644      3,112,161
  9      13,890,160      3,472,540
  10      13,376,136      3,344,034
  11      15,735,272      3,933,818
  12      15,138,472      3,784,618
  13      19,079,744      4,769,936
  14      15,138,472      3,784,618
  15      15,735,272      3,933,818
  16      13,376,136      3,344,034
  17      13,890,160      3,472,540
  18      12,448,644      3,112,161
  19      12,067,524      3,016,881
  20      10,403,516      2,600,879
  21       9,727,224      2,431,806
  22       7,835,348      1,958,837
  23       7,659,936      1,914,984
  24       5,464,716      1,366,179
  25       4,365,792      1,091,448
Total    275,305,224     68,826,306
(Usage of the Windows version <msq5e.exe>)
 1. Range of Central Value
   
Please choose the number of center of main. Two numbers, From and To, are set up.
    Each number of total counts will be displayed on lower text area after counting.
 
2. Counting Condition
    
Please choose whether the total is counted or 1/4 total is counted.
 
3. Display Condition
    Please choose every how many pieces of the found order is displayed.
    
Since time is taken as displaying all, there is the mode to display the order every 100 or 1000 pieces.
 4. Priority
   
 It can be changed in the range which can choose the priority of a program by Windows.
    
However, speed seldom changes in Windows2000/XP.
 
5. File
   
If the check box is checked, the found order can be outputted to a text file (CSV).
   
It is the file whose consecutive numbers and 25 numbers are divided with spaces, and made 1 set one line.

<The Linux version is a console program. Please type 'msq5 -h' to display brief help. >

The total of 6x6 magic square is not decided although a report is told that there is near 1,800 trillion order.

<A program to number the total of 6x6 magic squares (Windows version)>  New!!

Even if Pentium4 machine working at 3GHz is used, it is thought that it will take 220,500 years or more by the time
 the above program is finished. Therefore, please use moderately.


>> The Windows version program above-mentioned was created by Borland C++ Builder 6.
     Moreover, the Linux version was compiled by gcc-3.2.2-5.
>> Although the above-mentioned program is freeware, Netstaff Co.,Inc. owns copyright.
     If it is not the profit purpose, use freely.

>> Those who wish to reproduce need to inform by Mail.

[Exemption from responsibility]
Also what damage after using the above-mentioned program, Netstaff Co.,Inc. takes no responsibility.