Spijit

The only two digits found in all standard bases are 1 and 0. But they behave quite differently. Suppose you take the integers 1 to 100 and compare the number of 1s and 0s in the representation of each integer, n, in bases 2 to n-1. For example, 10 would look like this:

1010 in base 2
101 in base 3
22 in base 4
20 in base 5
14 in base 6
13 in base 7
12 in base 8
11 in base 9

So there are nine 1s and four 0s. If you check 1 to 100 using this all-base function, the count of 1s goes like this:

1, 1, 2, 3, 5, 5, 8, 5, 9, 9, 11, 10, 15, 12, 14, 13, 15, 12, 17, 14, 20, 19, 20, 15, 23, 19, 22, 22, 25, 24, 31, 21, 25, 24, 24, 27, 33, 27, 31, 29, 34, 29, 36, 30, 34, 35, 34, 30, 40, 33, 36, 35, 38, 34, 42, 37, 43, 40, 41, 37, 48, 39, 42, 42, 44, 43, 48, 43, 47, 46, 51, 42, 53, 44, 48, 50, 51, 50, 55, 48, 59, 55, 55, 54, 64, 57, 57, 55, 60, 57, 68, 60, 64, 63, 64, 59, 68, 58, 61, 63.

And the count of 0s goes like this:

0, 1, 0, 2, 1, 2, 0, 4, 4, 4, 2, 5, 1, 2, 2, 7, 4, 8, 4, 7, 4, 3, 1, 8, 4, 4, 6, 8, 4, 7, 1, 10, 8, 7, 7, 12, 5, 6, 5, 10, 4, 8, 2, 6, 7, 4, 2, 12, 6, 9, 7, 8, 4, 11, 6, 10, 5, 4, 2, 12, 2, 3, 5, 14, 11, 13, 7, 10, 8, 11, 5, 17, 7, 8, 10, 10, 8, 10, 4, 13, 12, 10, 8, 16, 8, 7, 7, 12, 6, 14, 6, 8, 5, 4, 4, 16, 6, 10, 11, 15.

The bigger the numbers get, the bigger the discrepancies get. Sometimes the discrepancy is dramatic. For example, suppose you represented the prime 1014719 in bases 2 to 1014718. How 0s would there be? And how many 1s? There are exactly nine zeroes:

1014719 = 11110111101110111111 in base 2 = 1220112221012 in base 3 = 40B27B in base 12 = 1509CE in base 15 = 10[670] in base 1007.

But there are 507723 ones. The same procedure applied to the next integer, 1014720, yields 126 zeroes and 507713 ones. However, there is a way to see that 1s and 0s in the all-base representation are behaving in a similar way. To do this, imagine listing the individual digits of n in bases 2 to n-1 (or just base 2, if n <= 3). When the digits aren’t individual they look like this:

1 = 1 in base 2
2 = 10 in base 2
3 = 11 in base 2
4 = 100 in base 2; 11 in base 3
5 = 101 in base 2; 12 in base 3; 11 in base 4
6 = 110 in base 2; 20 in base 3; 12 in base 4; 11 in base 5
7 = 111 in base 2; 21 in base 3; 13 in base 4; 12 in base 5; 11 in base 6
8 = 1000 in base 2; 22 in base 3; 20 in base 4; 13 in base 5; 12 in base 6; 11 in base 7
9 = 1001 in base 2; 100 in base 3; 21 in base 4; 14 in base 5; 13 in base 6; 12 in base 7; 11 in base 8
10 = 1010 in base 2; 101 in base 3; 22 in base 4; 20 in base 5; 14 in base 6; 13 in base 7; 12 in base 8; 11 in base 9

So the list would look like this:

1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 0, 2, 0, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 2, 1, 1, 1, 0, 0, 0, 2, 2, 2, 0, 1, 3, 1, 2, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 1, 1, 4, 1, 3, 1, 2, 1, 1, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 0, 1, 4, 1, 3, 1, 2, 1, 1

Suppose that these digits are compared against the squares of a counter-clockwise spiral on a rectangular grid. If the spiral digit is equal to 1, the square is filled in; if the spijit is not equal to 1, the square is left blank. The 1-spiral looks like this:
1spiral
Now try zero. If the spijit is equal to 0, the square is filled in; if not, the square is left blank. The 0-spiral looks like this:
0spiral
And here’s an animated gif of the n-spiral for n = 0..9:
animspiral

Spiral Archipelago

Incomplete map of Earthsea

Incomplete map of Earthsea

Ursula K. Le Guin, creatrix of Earthsea, is a much better writer than J.R.R. Tolkien, creator of Middle-earth: much more subtle, skilful and sophisticated. But for me Middle-earth has one big advantage over Earthsea: I can imagine Middle-earth really existing. I can’t say that for Earthsea, an archipelago-world of fishermen, goatherds and wizards. There’s something dead and disconnected about Earthsea. I’m not sure what it is, but it may have something to do with Le Guin’s dedicated political correctness.

For example, despite the northern European climate and culture on Earthsea, a sea-faring world with lots of rain, mist, snow and mountains, most of the people are supposed to have dark skins. The ones that don’t – the white-skinned, blond-haired Kargs – are the bloodthirsty baddies of A Wizard of Earthsea (1968), the first book in the series. Balls to biology, in other words: there’s propaganda to propagate. So it’s not surprising that Le Guin’s father was a famous and respected figure in the mostly disreputable discipline of anthropology. Earthsea is fantasy for Guardian-readers, in short.

But I still like the idea of an archipelago-world: sea and islands, islands and sea. As Le Guin herself says: “We all have archipelagos in our minds.” That’s one of the reasons I like the Ulam spiral: it reminds me of Earthsea. Unlike Earthsea, however, the sea and islands go on for ever. In the Ulam spiral, the islands are the prime numbers and the sea is the composite numbers. It’s based on a counter-clockwise spiral of integers, like this:

145←144←143←142←141←140139←138←137←136←135←134←133
 ↓                                               ↑
146 101←100←099←098←097←096←095←094←093←092←091 132
 ↓   ↓                                       ↑   ↑
147 102 065←064←063←062←061←060←059←058←057 090 131
 ↓   ↓   ↓                                  ↑   ↑
148 103 066 037←036←035←034←033←032←031 056 089 130
 ↓   ↓   ↓   ↓                       ↑   ↑   ↑   ↑
149 104 067 038 017←016←015←014←013 030 055 088 129
 ↓   ↓   ↓   ↓   ↓               ↑      ↑   ↑   ↑
150 105 068 039 018 005←004←003 012 029 054 087 128
 ↓   ↓   ↓   ↓   ↓   ↓       ↑   ↑   ↑   ↑   ↑   ↑
151 106 069 040 019 006 001002 011 028 053 086 127
 ↓   ↓   ↓   ↓   ↓   ↓           ↑      ↑   ↑   
152 107 070 041 020 007→008→009→010 027 052 085 126
 ↓   ↓   ↓   ↓   ↓                   ↑   ↑   ↑   ↑
153 108 071 042 021→022→023→024→025→026 051 084 125
 ↓   ↓   ↓   ↓                           ↑   ↑   ↑
154 109 072 043→044→045→046→047→048→049→050 083 124
 ↓   ↓   ↓                                   ↑   ↑
155 110 073→074→075→076→077→078→079→080→081→082 123
 ↓   ↓                                           ↑
156 111→112→113→114→115→116→117→118→119→120→121→122
 ↓                                                   ↑
157→158→159→160→161→162→163→164→165→166→167→168→169→170

The spiral is named after Stanislaw Ulam (1909-84), a Polish mathematician who invented it while doodling during a boring meeting. When numbers are represented as pixels and 1 is green, the spiral looks like this – note the unique “knee” formed by 2, 3 (directly above 2) and 11 (to the right of 2):

Ulam spiral

Ulam spiral (animated)

(If the image above does not animate, please try opening it in a new window.)

Some prime-pixels are isolated, like eyots or aits (small islands) in the number-sea, but some touch corner-to-corner and form larger units, larger islands. There are also prime-diamonds, like islands with lakes on them. The largest island, with 19 primes, may come very near the centre of the spiral:

island1

Island 1 = (5, 7, 17, 19, 23, 37, 41, 43, 47, 67, 71, 73, 79, 103, 107, 109, 113, 149, 151) (i=19) (x=-3, y=3, n=37) (n=1 at x=0, y=0)

Here are some more prime-islands – prIslands or priminsulas – in the Ulam-sea that I find interesting or attractive for one reason or other:

island2

Island 2 = (281, 283, 353, 431, 433, 521, 523, 617, 619, 719, 827, 829, 947) (i=13) (x=6, y=-12, n=619)


island3

Island 3 = (20347, 20921, 21499, 21503, 22091, 22093, 22691, 23293, 23297, 23909, 23911, 24533, 25163, 25801, 26449, 27103, 27767, 28439) (i=18) (x=-39, y=-81, n=26449)


island4

Island 4 = (537347, 540283, 543227, 546179, 549139, 552107, 555083, 558067, 561059, 561061, 564059, 564061, 567067, 570083, 573107, 573109) (i=16) (x=375, y=-315, n=561061)


island5

Island 5 = (1259047, 1263539, 1263541, 1268039, 1272547, 1277063, 1281587, 1286119, 1290659, 1295207, 1299763) (i=11) (x=-561, y=399, n=1259047)


island6

Island 6 = (1341841, 1346479, 1351123, 1355777, 1360439, 1360441, 1365107, 1365109, 1369783, 1369787, 1369789, 1374473, 1379167) (i=13) (x=-585, y=-297, n=1369783)


island7

Island 7 = (2419799, 2419801, 2426027, 2426033, 2432263, 2432267, 2438507, 2438509, 2444759, 2451017, 2457283, 2463557) (i=12) (x=558, y=780, n=2432263)


island8

Island 8 = (3189833, 3196979, 3196981, 3204137, 3204139, 3211301, 3211303, 3218471, 3218473, 3218477, 3225653) (i=11) (x=-894, y=858, n=3196981)