If is the order of a most-perfect magic square then . Assuming the prime decomposition of is
where for and
Let be the the sum of the exponents: .
Let be the canonical base for the representation of the integer numbers from to in a positional numeral system based on a mixture of prime numbers. It will contain -tuples:
is the weight of the canonical base . Both define together the positional numeral system.
The algorithm to find the representation of an integer between and is as follows:
initialisation
computations
, where is the first value of the -th 2-tuple in
, this is the computation of
Any number between and can now be written as
where and ∈
In the following the -tuple formed by the values is called coefficients in the positional numeral system defined by and .
Let be the set of the integer numbers from and . It is possible to choose a random -tuple named as follows:
initialisation
computations
a random element of is assigned to the the -th element of
Now it is possible to decompose each element of the -tuple in the positional numeral system defined by and calculating the coefficients for each element. Regrouping the appropriate coefficients it is possible to compute different -tuples where relates to the -th occurence of the prime number .
Each -tuple is used to construct an auxiliary square of order as follows:
the rows of with an odd number consist of the -tuples
the rows of with an even number consist of the prime number -complements of -tuples
for any value and ∈ its complement is
All steps from above can be repeated for columns. This is how a random -tuple named is choosen which will drive the computation of different -tuples where relates to the -th occurence of the prime number .
Finaly different auxiliary squares of order are generated as follows:
the columns of with an odd number consist of the transpose of the -tuples
the columns of with an even number consist of the prime number -complements of the transpose of the -tuples
The set of auxiliary squares has many interesting properties:
the sum of any 2×2 subsquare is constant inside a particular square
the sum of two cells with a distance of n/2 along a (major) diagonal is constant inside a particular square
choosing an ordered subset of auxiliary squares one can generate (one for each element) -tuples ; counting all different kind of -tuples show an equal distribution of these tuples
Magic squares of order contain all values from to .
where for and
In order to represent the integer numbers from to in a positional numeral system any base similar to the ones already used above needs to have tuples. Below a noncanocal base is presented::
Let be a permutation of the -tuples of where for two consecutive -tuples and
implies
Let be the set of all permutations of as described above. The question is what is the number of elements of . The requested number can be calculated with a function named which depends only on the number and values of the prime decomposition of ; i.e. . Examples of its calculation are given here.
Description about the calculation of will follow. One can see that if
From the construction one can see that this method allows the construction of
different squares. See matching A051235.
If where the function simplifies to and the number of most-perfect magic squares of order is ( partialy matching A151932 )