ⓘ This web page is about the old AlgoSim 2 software. Perhaps you are looking for the new Algosim 3 application?
AlgoSim
Homepage | Screenshots | Gallery of Visualisation | User's Guide | Function Reference | Download | FAQ | Support | Bugs and Solutions | Donate

Reference: magicSquare

magicSquare(N) returns a normal magic square of order N, i.e. a N×N matrix of the integers 1, 2, ..., N^2 such that the sum of the elements of each row, column, and diagonal equals the same number, the so called magic number of the matrix. A matrix has exactly two diagonals, in the usual sense.

The magic constant is always M = n(n^2 + 1) / 2. There is no magic square of order 2.

AlgoSim uses different algorithms when computing magic squares of

  1) odd order (N = 2k + 1),
  2) double even order (N = 4k), and
  3) singly even order (N = 4k + 2).

In general, the magic square of order N is not unique; AlgoSim will only produce *one* magic square of that order.