## Bordered Square Numbers

### Consecutively Concentric Squares

How many distinct consecutively concentric magic squares of each order are there?

Computed numbers for order n up to 14 are:

n Border Groups*  Distinct Squares
10 0
31 1
510 2,880
7185 6.1 × 1010
93,568 4.5 × 1022
1168,166 3.2 × 1039
131,324,149 5.4 × 1061
nBorder Groups* Distinct Squares
20 0
40 0
6140 567,705,600
828,490 6.7 × 1019
104,117,006 3.6 × 1036
12695,025,466 2.6 × 1059
14122,505,829,164 5.9 × 1088

* A border group is a configuration of the border numbers as corners, rest of row, and rest of column. For order 5, the bones numbers of these groups are:

```   Top Left   Top Right       Top Row           Right Column
Corner     Corner       Without Ends        Without Ends
---------- ----------   -----------------   ----------------
-12         10        -11    5    8        -6   -7   -9
-12         10        -11    6    7        -5   -8   -9
-11          5         -9    7    8         6  -10  -12
-10          6        -11    7    8         5   -9  -12
-10          6         -9    5    8         7  -11  -12

-9          7        -12    6    8         5  -10  -11
-9          7        -11    5    8         6  -10  -12
-8          6        -12    5    9         7  -10  -11
-8          6        -10    5    7         9  -11  -12
-7          5        -12    6    8         9  -10  -11
```

The corner complementary pairs are at opposite ends of the diagonals. The rest of row complementary pairs are at opposite ends of the columns. The rest of column complementary pairs are at opposite ends of the rows.

#### Formula

The number of distinct consecutively concentric squares of order n is:

```              number(n) = number(n-2) × r × c × p × p
```
```where:

c = computed number of border groups
p = permutations of 'row or column without ends' = (n-2)!
r = rotations and reflections = 8, (except = 1 for order 1)

For example:
```
```        number(3) =     1 × 1 ×   1 ×   1 ×   1 =           1
number(5) =     1 × 8 ×  10 ×   6 ×   6 =       2,880
number(6) =   880 × 8 × 140 ×  24 ×  24 = 567,705,600
number(7) = 2,880 × 8 × 185 × 120 × 120 = 6.14 × 1010
```

When (n-2) is the smallest center square order, i.e., 1 or 4, number(n-2) is the number of distinct magic squares; otherwise, number(n-2) is the number of distinct consecutively concentric magic squares.

### Concentric Squares

If the constraint that the nested squares consist of consecutive numbers is removed, there are many more concentric magic squares.

For order 5, the computed number of distinct concentric magic squares, (including the consecutively concentric squares), is 174,240. Program Order5Special.

For order 6, the number is 736,347,893,760, i.e., 7.36 × 1011. Program Order6Ccount.
Francis Gaspalou has confirmed this number, (July 2009).
Miguel Angel Amela also obtained this number, (April 2016).

For order 7, the number is 3,835,791,613,181,952,000, i.e., 3.84 × 1018. Program Order7Ccount.

##### REFERENCE

Amela, Miguel Angel    miguel.amel@gmail.com
General Pico - La Pampa - Argentina