Magiciprocal


A021023 Decimal expansion of 1/19.

0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8 [...] The magic square that uses the decimals of 1/19 is fully magic. — A021023 at the Online Encyclopedia of Integer Sequences

Year and Square

The simplest and in some ways greatest magic square is this:

6 1 8
7 5 3
2 9 4 (Magic total = 15)

All rows and columns sum to 15 and so do both diagonals. Using other sets of numbers, you can create an infinite number of further 3×3 magic squares. Here’s one using only prime numbers and 1:

43 01 67
61 37 13
07 73 31 (Magic=111)

The magic total is 111, which is 3 x 37, just as 15 = 3 x 5. It’s an interesting but untaxing exercise to prove that, for all 3×3 magic squares, the magic total is three times the central number. So you can use only prime numbers in a 3×3 square, but you can’t have a prime number as the magic total (unless you use fractions and so on).

And guess what? 2019 = 3 x 667, the first prime number after 666. So I decided to see if I could find an all-prime magic squares whose magic total was 2019. I found nine of them (and 9 = 3 x 3).

1117 0019 0883
0439 0673 0907
0463 1327 0229 (Magic=2019)

1069 0067 0883
0487 0673 0859
0463 1279 0277 (Magic=2019)

1063 0229 0727
0337 0673 1009
0619 1117 0283 (Magic=2019)

0883 0313 0823
0613 0673 0733
0523 1033 0463 (Magic=2019)

0619 0337 1063
1117 0673 0229
0283 1009 0727 (Magic=2019)

0463 0439 1117
1327 0673 0019
0229 0907 0883 (Magic=2019)

0463 0487 1069
1279 0673 0067
0277 0859 0883 (Magic=2019)

0379 0607 1033
1327 0673 0019
0313 0739 0967 (Magic=2019)

0523 0613 0883
1033 0673 0313
0463 0733 0823 (Magic=2019)

Square on a Three String

222 A.D. was the year in which the Emperor Heliogabalus was assassinated by his own soldiers. Exactly 1666 years later, the Anglo-Dutch classicist Sir Lawrence Alma-Tadema exhibited his painting The Roses of Heliogabalus (1888). I suggested in “Roses Are Golden” that Alma-Tadema must have chosen the year as deliberately as he chose the dimensions of his canvas, which, at 52″ x 84 1/8“, is an excellent approximation to the golden ratio.

But did Alma-Tadema know that lines at 0º and 222º divide a circle in the golden ratio? He could easily have done, just as he could easily have known that 222 precedes the 48th prime, 223. But it is highly unlikely that he knew that 223 yields a magic square whose columns, rows and diagonals all sum to 222. To create the square, simply list the 222 multiples of the reciprocal 1/223 in base 3, or ternary. The digits of the reciprocal repeat after exactly 222 digits and its multiples begin and end like this:

001/223 = 0.00001002102101021212111012022211122022... in base 3
002/223 = 0.00002011211202120201222101122200021121...
003/223 = 0.00010021021010212121110120222111220221...
004/223 = 0.00011100200112011110221210022100120020...
005/223 = 0.00012110002220110100102222122012012120...

[...]

218/223 = 0.22210112220002112122120000100210210102... in base 3
219/223 = 0.22211122022110211112001012200122102202...
220/223 = 0.22212201201212010101112102000111002001...
221/223 = 0.22220211011020102021000121100022201101...
222/223 = 0.22221220120121201010111210200011100200...

Each column, row and diagonal of ternary digits sums to 222. Here is the full n/223 square represented with 0s in grey, 1s in white and 2s in red:

(Click for larger)


It isn’t difficult to see that the white squares are mirror-symmetrical on a horizontal axis. Here is the symmetrical pattern rotated by 90º:

(Click for larger)


But why should the 1s be symmetrical? This isn’t something special to 1/223, because it happens with prime reciprocals like 1/7 too:

1/7 = 0.010212... in base 3
2/7 = 0.021201...
3/7 = 0.102120...
4/7 = 0.120102...
5/7 = 0.201021...
6/7 = 0.212010...

And you can notice something else: 0s mirror 2s and 2s mirror 0s. A related pattern appears in base 10:

1/7 = 0.142857...
2/7 = 0.285714...
3/7 = 0.428571...
4/7 = 0.571428...
5/7 = 0.714285...
6/7 = 0.857142...

The digit 1 in the decimal digits of n/7 corresponds to the digit 8 in the decimal digits of (7-n)/7; 4 corresponds to 5; 2 corresponds to 7; 8 corresponds to 1; 5 corresponds to 4; and 7 corresponds to 2. In short, if you’re given the digits d1 of n/7, you know the digits d2 of (n-7)/7 by the rule d2 = 9-d1.

Why does that happen? Examine these sums:

 1/7 = 0.142857142857142857142857142857142857142857...
+6/7 = 0.857142857142857142857142857142857142857142...
 7/7 = 0.999999999999999999999999999999999999999999... = 1.0

 2/7 = 0.285714285714285714285714285714285714285714...
+5/7 = 0.714285714285714285714285714285714285714285...
 7/7 = 0.999999999999999999999999999999999999999999... = 1.0

 3/7 = 0.428571428571428571428571428571428571428571...
+4/7 = 0.571428571428571428571428571428571428571428...
 7/7 = 0.999999999999999999999999999999999999999999... = 1.0

And here are the same sums in ternary (where the first seven integers are 1, 2, 10, 11, 12, 20, 21):

  1/21 = 0.010212010212010212010212010212010212010212...
+20/21 = 0.212010212010212010212010212010212010212010...
 21/21 = 0.222222222222222222222222222222222222222222... = 1.0

  2/21 = 0.021201021201021201021201021201021201021201...
+12/21 = 0.201021201021201021201021201021201021201021...
 21/21 = 0.222222222222222222222222222222222222222222... = 1.0

 10/21 = 0.102120102120102120102120102120102120102120...
+11/21 = 0.120102120102120102120102120102120102120102...
 21/21 = 0.222222222222222222222222222222222222222222... = 1.0

Accordingly, in base b with the prime p, the digits d1 of n/p correspond to the digits (p-n)/p by the rule d2 = (b-1)-d1. This explains why the 1s mirror themselves in ternary: 1 = 2-1 = (3-1)-1. In base 5, the 2s mirror themselves by the rule 2 = 4-2 = (5-1) – 2. In all odd bases, some digit will mirror itself; in all even bases, no digit will. The mirror-digit will be equal to (b-1)/2, which is always an integer when b is odd, but never an integer when b is even.

Here are some more examples of the symmetrical patterns found in odd bases:

Patterns of 1s in 1/19 in base 3


Patterns of 6s in 1/19 in base 13


Patterns of 7s in 1/19 in base 15


Elsewhere other-posted:

Roses Are Golden — more on The Roses of Heliogabalus (1888)
Three Is The Key — more on the 1/223 square

Lat’s That

In a magic square of numbers, all rows, columns and diagonals have the same sum, or magic total. Here is an example:

1*5*9
8*3*4
6*7*2

(mt=15)

Here’s another:

06*07*11*10
15*02*14*03
04*13*01*16
09*12*08*05

(mt=34)

And another:

04*25*20*10*06
01*13*11*21*19
23*09*07*08*18
15*16*03*14*17
22*02*24*12*05

(mt=65)

And another:

35*15*10*18*11*22
05*25*33*12*07*29
34*30*04*14*21*08
02*16*27*17*23*26
03*24*09*19*36*20
32*01*28*31*13*06

(mt=111)

In all those magic squares, the magic total is fixed: the sum of all numbers from 1 to 36 is 666, so any individual line in a 6×6 magic square has to equal 666 / 6 or 111. In other kinds of magic figure, this rule doesn’t apply:

2*7*3
4***8
6*5*1

(mt=12)

6*3*4
2***8
5*7*1

(mt=13)

8*5*1
2***6
4*3*7

(mt=14)

8*1*6
4***2
3*5*7

(mt=15)

Continue reading Lat’s That

More Multi-Magic

The answer, I’m glad to say, is yes. The question is: Can a prime magic-square nest inside a second prime magic-square that nests inside a third prime magic-square? I asked this in Multi-Magic, where I described how a magic square is a square of numbers where all rows, all columns and both diagonals add to the same number, or magic total. This magic square consists entirely of prime numbers, or numbers divisible only by themselves and 1:

43 | 01 | 67
61 | 37 | 13
07 | 73 | 31

Base = 10, magic total = 111

It nests inside this prime magic-square, whose digit-sums in base-97 re-create it:

0619  =  [06][37] | 0097  =  [01][00] | 1123  =  [11][56]
1117  =  [11][50] | 0613  =  [06][31] | 0109  =  [01][12]
0103  =  [01][06] | 1129  =  [11][62] | 0607  =  [06][25]

Base = 97, magic total = 1839

And that prime magic-square nests inside this one:

2803  =  [1][0618] | 2281  =  [1][0096] | 3307  =  [1][1122]
3301  =  [1][1116] | 2797  =  [1][0612] | 2293  =  [1][0108]
2287  =  [1][0102] | 3313  =  [1][1128] | 2791  =  [1][0606]

Base = 2185, magic total = 8391

I don’t know whether that prime magic-square nests inside a fourth square, but a 3-nest is good for 3×3 magic squares. On the other hand, this famous 3×3 magic square is easy to nest inside an infinite series of other magic squares:

6 | 1 | 8
7 | 5 | 3
2 | 9 | 4

Base = 10, magic total = 15

It’s created by the digit-sums of this square in base-9 (“14 = 15” means that the number 14 is represented as “15” in base-9):

14 = 15 → 6 | 09 = 10 → 1 | 16 = 17 → 8
15 = 16 → 7 | 13 = 14 → 5 | 11 = 12 → 3
10 = 11 → 2 | 17 = 18 → 9 | 12 = 13 → 4

Base = 9, magic total = 39


And that square in base-9 is created by the digit-sums of this square in base-17:

30 = 1[13] → 14 | 25 = 00018 → 09 | 32 = 1[15] → 16
31 = 1[14] → 15 | 29 = 1[12] → 13 | 27 = 1[10] → 11
26 = 00019 → 10 | 33 = 1[16] → 17 | 28 = 1[11] → 12

Base = 17, magic total = 87

And so on:

62 = 1[29] → 30 | 57 = 1[24] → 25 | 64 = 1[31] → 32
63 = 1[30] → 31 | 61 = 1[28] → 29 | 59 = 1[26] → 27
58 = 1[25] → 26 | 65 = 1[32] → 33 | 60 = 1[27] → 28

Base = 33, magic total = 183

126 = 1[61] → 62 | 121 = 1[56] → 57 | 128 = 1[63] → 64
127 = 1[62] → 63 | 125 = 1[60] → 61 | 123 = 1[58] → 59
122 = 1[57] → 58 | 129 = 1[64] → 65 | 124 = 1[59] → 60

Base = 65, magic total = 375

Previously Pre-Posted (please peruse):

Multi-Magic

Multi-Magic

A magic square is a square of numbers in which all rows, all columns and both diagonals add to the same number, or magic total. The simplest magic square using distinct numbers is this:

6 1 8
7 5 3
2 9 4

It’s easy to prove that the magic total of a 3×3 magic square must be three times the central number. Accordingly, if the central number is 37, the magic total must be 111. There are lots of ways to create a magic square with 37 at its heart, but this is my favourite:

43 | 01 | 67
61 | 37 | 13
07 | 73 | 31

The square is special because all the numbers are prime, or divisible by only themselves and 1 (though 1 itself is not usually defined as prime in modern mathematics). I like the 37-square even more now that I’ve discovered it can be found inside another all-prime magic square:

0619 = 0006[37] | 0097 = 00000010 | 1123 = [11][56]
1117 = [11][50] | 0613 = 0006[31] | 0109 = 0001[12]
0103 = 00000016 | 1129 = [11][62] | 0607 = 0006[25]

Magic total = 1839

The square is shown in both base-10 and base-97. If the digit-sums of the base-97 square are calculated, this is the result (e.g., the digit-sum of 6[37][b=97] = 6 + 37 = 43):

43 | 01 | 67
61 | 37 | 13
07 | 73 | 31

This makes me wonder whether the 613-square might nest in another all-prime square, and so on, perhaps ad infinitum [Update: yes, the 613-square is a nestling]. There are certainly many nested all-prime squares. Here is square-631 in base-187:

661 = 003[100] | 379 = 00000025 | 853 = 004[105]
823 = 004[075] | 631 = 003[070] | 439 = 002[065]
409 = 002[035] | 883 = 004[135] | 601 = 003[040]

Magic total = 1893

Digit-sums:

103 | 007 | 109
079 | 073 | 067
037 | 139 | 043

Magic total = 219

There are also all-prime magic squares that have two kinds of nestlings inside them: digit-sum magic squares and digit-product magic squares. The digit-product of a number is calculated by multiplying its digits (except 0): digit-product(37) = 3 x 7 = 21, digit-product(103) = 1 x 3 = 3, and so on. In base-331, this all-prime magic square yields both a digit-sum square and a digit-product square:

503 = 1[172] | 359 = 1[028] | 521 = 1[190]
479 = 1[148] | 461 = 1[130] | 443 = 1[112]
401 = 1[070] | 563 = 1[232] | 419 = 1[088]

Magic total = 1383

Digit-sums:

173 | 029 | 191
149 | 131 | 113
071 | 233 | 089

Magic total = 393

Digit-products:

172 | 028 | 190
148 | 130 | 112
070 | 232 | 088

Magic total = 390

Here are two more twin-bearing all-prime magic squares:

Square-719 in base-451:

761 = 1[310] | 557 = 1[106] | 839 = 1[388]
797 = 1[346] | 719 = 1[268] | 641 = 1[190]
599 = 1[148] | 881 = 1[430] | 677 = 1[226]

Magic total = 2157

Digit-sums:

311 | 107 | 389
347 | 269 | 191
149 | 431 | 227

Magic total = 807

Digit-products:

310 | 106 | 388
346 | 268 | 190
148 | 430 | 226

Magic total = 804

Square-853 in base-344:

883 = 2[195] | 709 = 2[021] | 967 = 2[279]
937 = 2[249] | 853 = 2[165] | 769 = 2[081]
739 = 2[051] | 997 = 2[309] | 823 = 2[135]

Magic total = 2559

Digit-sums:

197 | 023 | 281
251 | 167 | 083
053 | 311 | 137

Magic total = 501

Digit-products:

390 | 042 | 558
498 | 330 | 162
102 | 618 | 270

Magic total = 990

Proviously Post-Posted (please peruse):

More Multi-Magic

Three Is The Key

If The Roses of Heliogabalus (1888) is any guide, Sir Lawrence Alma-Tadema (1836-1912) thought that 222 is a special number. But his painting doesn’t exhaust its secrets. To get to another curiosity of 222, start with 142857. As David Wells puts it in his Penguin Dictionary of Curious and Interesting Numbers (1986), 142857 is a “number beloved of all recreational mathematicians”. He then describes some of its properties, including this:

142857 x 1 = 142857
142857 x 2 = 285714
142857 x 3 = 428571
142857 x 4 = 571428
142857 x 5 = 714285
142857 x 6 = 857142

The multiples are cyclic permutations: the order of the six numbers doesn’t change, only their starting point. Because each row contains the same numbers, it sums to the same total: 1 + 4 + 2 + 8 + 5 + 7 = 27. And because each row begins with a different number, each column contains the same six numbers and also sums to 27, like this:

1 4 2 8 5 7
+ + + + + +
2 8 5 7 1 4
+ + + + + +
4 2 8 5 7 1
+ + + + + +
5 7 1 4 2 8
+ + + + + +
7 1 4 2 8 5
+ + + + + +
8 5 7 1 4 2

= = = = = =

2 2 2 2 2 2
7 7 7 7 7 7

If the diagonals of the square also summed to the same total, the multiples of 142857 would create a full magic square. But the diagonals don’t have the same total: the left-right diagonal sums to 31 and the right-left to 23 (note that 31 + 23 = 54 = 27 x 2).

But where does 142857 come from? It’s actually the first six digits of the reciprocal of 7, i.e. 1/7 = 0·142857… Those six numbers repeat for ever, because 1/7 is a prime reciprocal with maximum period: when you calculate 1/7, all integers below 7 are represented in the remainders. The square of multiples above is simply another way of representing this:

1/7 = 0·142857…
2/7 = 0·285714…
3/7 = 0·428571…
4/7 = 0·571428…
5/7 = 0·714285…
6/7 = 0·857142…
7/7 = 0·999999…

The prime reciprocals 1/17 and 1/19 also have maximum period, so the squares created by their multiples have the same property: each row and each column sums to the same total, 72 and 81, respectively. But the 1/19 square has an additional property: both diagonals sum to 81, so it is fully magic:

01/19 = 0·0 5 2 6 3 1 5 7 8 9 4 7 3 6 8 4 2 1
02/19 = 0·1 0 5 2 6 3 1 5 7 8 9 4 7 3 6 8 4 2…
03/19 = 0·1 5 7 8 9 4 7 3 6 8 4 2 1 0 5 2 6 3…
04/19 = 0·2 1 0 5 2 6 3 1 5 7 8 9 4 7 3 6 8 4…
05/19 = 0·2 6 3 1 5 7 8 9 4 7 3 6 8 4 2 1 0 5…
06/19 = 0·3 1 5 7 8 9 4 7 3 6 8 4 2 1 0 5 2 6…
07/19 = 0·3 6 8 4 2 1 0 5 2 6 3 1 5 7 8 9 4 7…
08/19 = 0·4 2 1 0 5 2 6 3 1 5 7 8 9 4 7 3 6 8…
09/19 = 0·4 7 3 6 8 4 2 1 0 5 2 6 3 1 5 7 8 9…
10/19 = 0·5 2 6 3 1 5 7 8 9 4 7 3 6 8 4 2 1 0…
11/19 = 0·5 7 8 9 4 7 3 6 8 4 2 1 0 5 2 6 3 1…
12/19 = 0·6 3 1 5 7 8 9 4 7 3 6 8 4 2 1 0 5 2…
13/19 = 0·6 8 4 2 1 0 5 2 6 3 1 5 7 8 9 4 7 3…
14/19 = 0·7 3 6 8 4 2 1 0 5 2 6 3 1 5 7 8 9 4…
15/19 = 0·7 8 9 4 7 3 6 8 4 2 1 0 5 2 6 3 1 5…
16/19 = 0·8 4 2 1 0 5 2 6 3 1 5 7 8 9 4 7 3 6…
17/19 = 0·8 9 4 7 3 6 8 4 2 1 0 5 2 6 3 1 5 7…
18/19 = 0·9 4 7 3 6 8 4 2 1 0 5 2 6 3 1 5 7 8

First line = 0 + 5 + 2 + 6 + 3 + 1 + 5 + 7 + 8 + 9 + 4 + 7 + 3 + 6 + 8 + 4 + 2 + 1 = 81

Left-right diagonal = 0 + 0 + 7 + 5 + 5 + 9 + 0 + 3 + 0 + 4 + 2 + 8 + 7 + 5 + 6 + 7 + 5 + 8 = 81

Right-left diagonal = 9 + 9 + 2 + 4 + 4 + 0 + 9 + 6 + 9 + 5 + 7 + 1 + 2 + 4 + 3 + 2 + 4 + 1 = 81

In base 10, this doesn’t happen again until the 1/383 square, whose magic total is 1719 (= 383-1 x 10-1 / 2). But recreational maths isn’t restricted to base 10 and lots more magic squares are created by lots more primes in lots more bases. The prime 223 in base 3 is one of them. Here the first line is

1/223 = 1/220213 = 0·

0000100210210102121211101202221112202
2110211112001012200122102202002122220
2110110201020210001211000222011010010
2222122012012120101011121020001110020
0112011110221210022100120020220100002
0112112021202012221011222000211212212…

The digits sum to 222, so 222 is the magic total for all rows and columns of the 1/223 square. It is also the total for both diagonals, so the square is fully magic. I doubt that Alma-Tadema knew this, because he lived before computers made calculations like that fast and easy. But he was probably a Freemason and, if so, would have been pleased to learn that 222 had a link with squares.

Central Government

A magic square is a square of numbers in which all rows and columns and both diagonals add to the same number, or the magic total. The 3×3 magic square, also known as the Lo Shu square (“scroll of the River Lo” square), uses the numbers 1 to 9 and has a magic total of 15. I haven’t seen it explicitly stated anywhere on the net, perhaps because it’s trivially obvious to proper mathematicians, but in this and other 3×3 magic squares, the magic total must be three times the central number. Here is the proof:

4 9 2
3 5 7
8 1 6
a b c
d e f
g h i

1. a + b + c = a + e + i = b + e + h = c + e + g

2. 3(a + b + c) = (a + e + i) + (b + e + h) + (c + e + g)

3. 3a + 3b + 3c = 3e + a + i + b + h + c + g

4. 2a + 2b + 2c = 3e + g + h + i

5. 2a + 2b + 2c – (g + h + i) = 3e

6. 3e = a + b + c = magic total

Update: In fact, this fact about 3×3 squares is mentioned a lot on the web. See, for example, Negative Magic Squares, which describes a proof discovered by Māori mathematicians in 736 B.C.E.

Some 3×3 magic squares using entirely prime numbers (except for 1 in the first square):

00043 00001 00067
00061 00037 00013
00007 00073 00031 mt = 111 = 37 x 3

00071 00005 00101
00089 00059 00029
00017 00113 00047 mt = 177 = 59 x 3

00083 00029 00101
00089 00071 00053
00041 00113 00059 mt = 213 = 71 x 3

00103 00007 00109
00079 00073 00067
00037 00139 00043 mt = 219 = 73 x 3

00107 00011 00149
00131 00089 00047
00029 00167 00071 mt = 267 = 89 x 3

00139 00007 00163
00127 00103 00079
00043 00199 00067 mt = 309 = 103 x 3

12841 09769 15013
14713 12541 10369
10069 15313 12241 mt = 37623 = 12541 x 3

12721 07753 17167
16993 12547 08101
07927 17341 12373 mt = 37641 = 12547 x 3

13183 08059 16417
15787 12553 09319
08689 17047 11923 mt = 37659 = 12553 x 3