Graph durch Euler

This is the famous Ulam spiral, in which prime numbers are represented on filled squares on a square spiral:

The Ulam spiral


I like the way the spiral sits between chaos and calm. It’s not wholly random and it’s not wholly regular — it’s betwixt and between. You get a similar chaos-and-calm vibe from a graph for a function called Euler phi. And primes are at work there too. Here’s the graph from Wikipedia:

Graph of eulerphi(n) = φ(n) (see Euler’s totient function)


But what is the Euler phi function? For any integer n, eulerphi(n) gives you the count of numbers < n that are relatively prime to n. That is, the count of numbers < n that have no common factors with n other than one. You can see how eulerphi(n) works by considering whether you can simplify the fraction a/b, where a = 1..n-1 and b = n:

φ(6) = 2
1/6 (1)
2/6 → 1/3
3/6 → 1/2
4/6 → 2/3
5/6, ∴ φ(6) = 2


φ(7) = 6
1/7 (1)
2/7 (2)
3/7 (3)
4/7 (4)
5/7 (5)
6/7, ∴ φ(7) = 6


φ(12) = 4
1/12 (1)
2/12 → 1/6
3/12 → 1/4
4/12 → 1/3
5/12 (2)
6/12 → 1/2
7/12 (3)
8/12 → 2/3
9/12 → 3/4
10/12 → 5/6
11/12, ∴ φ(12) = 4


φ(13) = 12
1/13 (1)
2/13 (2)
3/13 (3)
4/13 (4)
5/13 (5)
6/13 (6)
7/13 (7)
8/13 (8)
9/13 (9)
10/13 (10)
11/13 (11)
12/13, ∴ φ(13) = 12


As you can see, eulerphi(n) = n-1 for primes. Now you know what the top line of the Eulerphi graph is. It’s the primes. Here’s a bigger version of the graph:

Graph of eulerphi(n) = φ(n)


Unlike the Ulam spiral, however, the Eulerphi graph is cramped. But it’s easy to stretch it. You can represent φ(n) as a fraction between 0 and 1 like this: phifrac(n) = φ(n) / (n-1). Using phifrac(n), you can create Eulerphi bands, like this:

Eulerphi band, n <= 1781


Eulerphi band, n <= 3561


Eulerphi band, n <= 7121


Eulerphi band, n <= 14241


Or you can create Eulerphi discs, like this:

Eulerphi disc, n <= 1601


Eulerphi disc, n <= 3201


Eulerphi disc, n <= 6401


Eulerphi disc, n <= 12802


Eulerphi disc, n <= 25602


But what is the bottom line of the Eulerphi bands and inner ring of the Eulerphi discs, where φ(n) is smallest relative to n? Well, the top line or outer ring is the primes and the bottom line or inner ring is the primorials (and their multiples). The function primorial(n) is the multiple of the first n primes:

primorial(1) = 2
primorial(2) = 2*3 = 6
primorial(3) = 2*3*5 = 30
primorial(4) = 2*3*5*7 = 210
primorial(5) = 2*3*5*7*11 = 2310
primorial(6) = 2*3*5*7*11*13 = 30030
primorial(7) = 2*3*5*7*11*13*17 = 510510
primorial(8) = 2*3*5*7*11*13*17*19 = 9699690
primorial(9) = 2*3*5*7*11*13*17*19*23 = 223092870
primorial(10) = 2*3*5*7*11*13*17*19*23*29 = 6469693230


Here are the numbers returning record lows for φfrac(n) = φ(n) / (n-1):

φ(4) = 2 (2/3 = 0.666…)
4 = 2^2
φ(6) = 2 (2/5 = 0.4)
6 = 2.3
φ(12) = 4 (4/11 = 0.363636…)
12 = 2^2.3
[…]
φ(30) = 8 (8/29 = 0.275862…)
30 = 2.3.5
φ(60) = 16 (16/59 = 0.27118…)
60 = 2^2.3.5
[…]
φ(210) = 48 (48/209 = 0.229665…)
210 = 2.3.5.7
φ(420) = 96 (96/419 = 0.2291169…)
420 = 2^2.3.5.7
φ(630) = 144 (144/629 = 0.228934…)
630 = 2.3^2.5.7
[…]
φ(2310) = 480 (480/2309 = 0.2078822…)
2310 = 2.3.5.7.11
φ(4620) = 960 (960/4619 = 0.20783719…)
4620 = 2^2.3.5.7.11
[…]
30030 = 2.3.5.7.11.13
φ(60060) = 11520 (11520/60059 = 0.191811385…)
60060 = 2^2.3.5.7.11.13
φ(90090) = 17280 (17280/90089 = 0.1918103209…)
90090 = 2.3^2.5.7.11.13
[…]
φ(510510) = 92160 (92160/510509 = 0.18052571061…)
510510 = 2.3.5.7.11.13.17
φ(1021020) = 184320 (184320/1021019 = 0.18052553…)
1021020 = 2^2.3.5.7.11.13.17
φ(1531530) = 276480 (276480/1531529 = 0.180525474868579…)
1531530 = 2.3^2.5.7.11.13.17
φ(2042040) = 368640 (368640/2042039 = 0.18052544540040616…)
2042040 = 2^3.3.5.7.11.13.17

Primal Polynomial

n² + n + 17 is one of the best-known polynomial formulas for primes. Its values for n = 0 to 15 are all prime, starting with 17 and ending with 257. — David Wells in The Penguin Dictionary of Curious and Interesting Numbers (1986), entry for “17”

• 17, 19, 23, 29, 37, 47, 59, 73, 89, 107, 127, 149, 173, 199, 227, 257

Primal Pellicles

Numbers have thin skins. And they’re easily replaced. Take 71624133. Here it is permuting its pellicles:

71624133 in base 10 = 100010001001110010111000101 in base 2 = 11222202212211200 in b3 = 10101032113011 in b4 = 121313433013 in b5 = 11035053113 in b6 = 1526536500 in b7 = 421162705 in b8 = 158685750 in b9 = 374802A9 in b11 = 1BBA1199 in b12 = 11AB9B59 in b13 = 9726137 in b14 = 644BE73 in b15 = F3855B7 in b16

But if digits are the skin of 71624133, what are its bones? Well, you could say the skeleton of a number, something that doesn’t change from base to base, is its prime factorization:

71624133 = 32 × 72 × 162413

But the primes themselves are numbers, so they’re wearing pellicles too. And it turns out that, in base 10, the pellicles of the prime factors of 71624133 match the pellicle of 71624133 itself:

71624133 = 32.72.162413

Here’s a list of primal pellicles in base 10:

735 = 3.5.72
3792 = 24.3.79
1341275 = 52.13.4127
13115375 = 53.7.13.1153
22940075 = 52.229.4007
29373375 = 3.53.29.37.73
71624133 = 32.72.162413
311997175 = 52.7.172.31.199
319953792 = 27.3.53.79.199
1019127375 = 32.53.7.127.1019
1147983375 = 3.53.7.11.83.479
1734009275 = 52.173.400927
5581625072 = 24.5581.62507
7350032375 = 53.7.23.73.5003
17370159615 = 34.5.17.59.61.701
33061224492 = 22.33.306122449
103375535837 = 72.37.103.553583
171167303912 = 23.11.172.6730391
319383665913 = 3.133.19.383.6659
533671737975 = 34.52.17.53.367.797
2118067737975 = 32.52.7.79.211.80677
3111368374257 = 3.112.132.683.74257
3216177757191 = 3.73.191.757.21617
3740437158475 = 52.37.4043715847
3977292332775 = 3.52.292.233.277.977
4417149692375 = 53.7.23.4969.44171
7459655393232 = 24.32.72.23.45965539
7699132721175 = 3.52.72.27211.76991
7973529228735 = 3.5.7.972.2287.3529
10771673522535 = 34.5.67.71.107.52253

You can find them at the Online Encyclopedia of Integer Sequences under A121342, “Composite numbers that are a concatenation of their distinct prime divisors in some order.” But what about pairs of primal pellicles, that is, pairs of numbers where the prime factors of each form the pellicle of the other?

35 = 5.775 = 3.52
1275 = 3.52.173175 = 52.127
131715 = 32.5.2927329275 = 52.13171
3199767 = 3.359.297135932971 = 3.19.67.972
14931092 = 22.11.61.5563116155632 = 24.3.109.1492

And here are a few primal pellicles I’ve found in other bases:

Primal Pellicles in Base 2

1111011011110 = 10.1110.110110111 in b2 = 7902 = 2.32.439 in b10
1110001100110111 = 1110.10111.100011001 in b2 = 58167 = 32.23.281 in b10
1111011011011110 = 10.1110.110110110111 in b2 = 63198 = 2.32.3511 in b10
11101001100001101 = 1110.101.101001100001 in b2 = 119565 = 32.5.2657 in b10
1111011011011011110 = 10.1110.110110110110111 in b2 = 505566 = 2.32.28087 in b10
1111011111101111011 = 1110.1011.10111.11011111 in b2 = 507771 = 32.11.23.223 in b10


Primal Pellicles in Base 3

121022 = 210.12.102 in b3 = 440 = 23.5.11 in b10
212212 = 22.21.212 in b3 = 644 = 22.7.23 in b10
20110112 = 210.201.1011 in b3 = 4712 = 23.19.31 in b10
21110110 = 10.212.1101 in b3 = 5439 = 3.72.37 in b10
121111101 = 122.111.1101 in b3 = 12025 = 52.13.37 in b10
222112121 = 22.21.221121 in b3 = 19348 = 22.7.691 in b10
2202122021 = 22.2021.22021 in b3 = 54412 = 22.61.223 in b10
120212201221 = 2.122.21.201.1202 in b3 = 312550 = 2.52.7.19.47 in b10


Primal Pellicles in Base 7

2525 = 2.52.25 in b7 = 950 = 2.52.19 in b10
3210 = 2.34.10 in b7 = 1134 = 2.34.7 in b10
5252 = 2.52.52 in b7 = 1850 = 2.52.37 in b10
332616 = 33.16.326 in b7 = 58617 = 33.13.167 in b10
336045 = 32.5.3604 in b7 = 59715 = 32.5.1327 in b10
2251635 = 22.3.5.16.252 in b7 = 281580 = 22.3.5.13.192 in b10


Primal Pellicles in Base 11

253 = 22.3.52 in b11 = 300 = 22.3.52 in b10
732 = 2.32.72 in b11 = 882 = 2.32.72 in b10
2123 = 23.33.12 in b11 = 2808 = 23.33.13 in b10
3432 = 25.3.43 in b11 = 4512 = 25.3.47 in b10
3710 = 32.72.10 in b11 = 4851 = 32.72.11 in b10
72252 = 23.72.225 in b11 = 105448 = 23.72.269 in b10


Primal Pellicles in Base 15

275 = 24.5.7 in b15 = 560 = 24.5.7 in b10
2D5 = 2.52.D in b15 = 650 = 2.52.13 in b10
2CD5 = 2.52.CD in b15 = 9650 = 2.52.193 in b10
7BE3 = 3.72.BE in b15 = 26313 = 3.72.179 in b10
21285 = 24.52.128 in b15 = 105200 = 24.52.263 in b10

The Fatal Factory

I can’t remember where I came across this clever little puzzle and what precise form it took, but here’s my version of it:

A famously eccentric inventor and recreational mathematician has invited you to tour the factory where his company manufactures locks, keys, safes, cash-boxes and so on. At the end of the tour he brings you to a conference room, pours you a glass of wine, and invites you to test your wits against a puzzle. He points out that a hundred numbered boxes have been set out on two long tables in the room. You sip your wine as you listen to him explain that each box is locked and contains a slip of paper bearing a number between 0 and 9. If you accept the challenge, the inventor will order a hundred workers to walk in turn past the boxes, using a master-key to unlock or lock the boxes like this:

The first worker will use the key on every box (boxes #1,2,3…), the second worker will use the key on every second box (boxes #2,4,6…), the third worker the key on every third box (boxes #3,6,9…), and so on.

Now, you can’t tell by simply looking at a box whether it’s unlocked or not, but it’s obvious that the first box will be unlocked when all that is over. Box #1 is originally locked and the master-key will be used on it just once. But how many other boxes will be unlocked? If you can choose nothing but the unlocked boxes, you get to keep the contents. Otherwise you get nothing. That is, if you choose one or more locked boxes, you get nothing.

And what good are the contents of the unlocked boxes? Well, if you take the numbered slips of paper they contain in order, they will give you the combination of a locked safe the inventor now points out in the wall behind you. The safe contains the antidote for the deadly but slow-acting poison he secretly slipped into the wine you have been sipping as you listened to him explain the details of the puzzle. So you have to choose all and only the unlocked boxes to save your life. Can you do it?


Solution

I’m sure there’s a simpler explanation of which boxes will be unlocked, but here’s my complicated one:

Whether box #n is locked or unlocked in the end depends on how many divisors the number n has. If it has an even number of divisors, it will be locked; if it has an odd number of divisors, it will be unlocked. Take box #12. The number 12 has six divisors: 1, 2, 3, 4, 6 and 12. So workers #1, #3 and #6 will unlock it with the master-key, but workers #2, #4 and #12 will lock it again. Worker #12 will be the final worker to use the master-key on the box, so it will be locked.

Now take box #16. The number #16 has five divisors: 1, 2, 4, 8 and 16. So workers #1, #4 and #16 will unlock the box with the master-key, while workers #2 and #8 will lock it. Worker #16 will be the final worker to use the master-key on the box, so it will be unlocked.

In other words, the puzzle reduces to this: Which numbers from 1 to 100 have an odd number of divisors? To work out the number of divisors n has, you add 1 to the exponent of each of its prime factors and multiply the results. For example, 24 has eight divisors thus:

• 24 = 2^3 * 3^1 → (3+1) * (1+1) = 4 * 2 = 8, so 24 has eight divisors: 1, 2, 3, 4, 6, 8, 12, 24

But 36 has nine divisors thus:

• 36 = 2^2 * 3^2 → (2+1) * (2+1) = 3 * 3 = 9, so 36 has nine divisors: 1, 2, 3, 4, 6, 9, 12, 18, 36

36 demonstrates that a number has to have only even exponents on its prime factors to have an odd number of divisors (the only number without prime factors is 1, which has one divisor, namely itself). Numbers with only even exponents on their prime factors are square numbers:

• 4 = 2^2 → (2+1) = 3, so 4 has three divisors: 1, 2, 4
• 9 = 3^2 → (2+1) = 3, so 9 has three divisors: 1, 3, 9
• 16 = 2^4 → (4+1) = 5, so 16 has five divisors: 1, 2, 4, 8, 16
• 25 = 5^2 → (2+1) = 3, so 25 has divisors: 1, 5, 25
• 36 = 2^2 * 3^2 → (2+1) * (2+1) = 3 * 3 = 9, so 36 has nine divisors: 1, 2, 3, 4, 6, 9, 12, 18, 36
• 49 = 7^2 → (2+1) = 3, so 49 has three divisors: 1, 7, 49
• 64 = 2^6 → (6+1) = 7, so 64 has seven divisors: 1, 2, 4, 8, 16, 32, 64
• 81 = 3^4 → (4+1) = 5, so 81 has five divisors: 1, 3, 9, 27, 81
• 100 = 2^2 * 5^2 → (2+1) * (2+1) = 3 * 3 = 9, so 100 has nine divisors: 1, 2, 4, 5, 10, 20, 25, 50, 100

So if you choose boxes #1, #4, #9, #16, #25, #36, #49, #64, #81 and #100, you’ll get the combination for the safe and save your life.


Appendix

Here’s the full description of what happens to the boxes:

• box #1 is unlocked by worker #1 and locked by no-one, therefore it’s unlocked
• box #2 is unlocked by worker #1 and locked by worker #2, therefore it’s locked
• box #3 is unlocked by worker #1 and locked by worker #3, therefore it’s locked
• box #4 is unlocked by workers #1 and #4, and locked by worker #2, therefore it’s unlocked
• box #5 is unlocked by worker #1 and locked by worker #5, therefore it’s locked
• box #6 is unlocked by workers #1 and #3, and locked by workers #2 and #6, therefore it’s locked
• box #7 is unlocked by worker #1 and locked by worker #7, therefore it’s locked
• box #8 is unlocked by workers #1 and #4, and locked by workers #2 and #8, therefore it’s locked
• box #9 is unlocked by workers #1 and #9, and locked by worker #3, therefore it’s unlocked
• box #10 is unlocked by workers #1 and #5, and locked by workers #2 and #10, therefore it’s locked
• box #11 is unlocked by worker #1 and locked by worker #11, therefore it’s locked
• box #12 is unlocked by workers #1, #3 and #6, and locked by workers #2, #4 and #12, therefore it’s locked
• box #13 is unlocked by worker #1 and locked by worker #13, therefore it’s locked
• box #14 is unlocked by workers #1 and #7, and locked by workers #2 and #14, therefore it’s locked
• box #15 is unlocked by workers #1 and #5, and locked by workers #3 and #15, therefore it’s locked
• box #16 is unlocked by workers #1, #4 and #16, and locked by workers #2 and #8, therefore it’s unlocked
• box #17 is unlocked by worker #1 and locked by worker #17, therefore it’s locked
• box #18 is unlocked by workers #1, #3 and #9, and locked by workers #2, #6 and #18, therefore it’s locked
• box #19 is unlocked by worker #1 and locked by worker #19, therefore it’s locked
• box #20 is unlocked by workers #1, #4 and #10, and locked by workers #2, #5 and #20, therefore it’s locked
• box #21 is unlocked by workers #1 and #7, and locked by workers #3 and #21, therefore it’s locked
• box #22 is unlocked by workers #1 and #11, and locked by workers #2 and #22, therefore it’s locked
• box #23 is unlocked by worker #1 and locked by worker #23, therefore it’s locked
• box #24 is unlocked by workers #1, #3, #6 and #12, and locked by workers #2, #4, #8 and #24, therefore it’s locked
• box #25 is unlocked by workers #1 and #25, and locked by worker #5, therefore it’s unlocked
• box #26 is unlocked by workers #1 and #13, and locked by workers #2 and #26, therefore it’s locked
• box #27 is unlocked by workers #1 and #9, and locked by workers #3 and #27, therefore it’s locked
• box #28 is unlocked by workers #1, #4 and #14, and locked by workers #2, #7 and #28, therefore it’s locked
• box #29 is unlocked by worker #1 and locked by worker #29, therefore it’s locked
• box #30 is unlocked by workers #1, #3, #6 and #15, and locked by workers #2, #5, #10 and #30, therefore it’s locked
• box #31 is unlocked by worker #1 and locked by worker #31, therefore it’s locked
• box #32 is unlocked by workers #1, #4 and #16, and locked by workers #2, #8 and #32, therefore it’s locked
• box #33 is unlocked by workers #1 and #11, and locked by workers #3 and #33, therefore it’s locked
• box #34 is unlocked by workers #1 and #17, and locked by workers #2 and #34, therefore it’s locked
• box #35 is unlocked by workers #1 and #7, and locked by workers #5 and #35, therefore it’s locked
• box #36 is unlocked by workers #1, #3, #6, #12 and #36, and locked by workers #2, #4, #9 and #18, therefore it’s unlocked
• box #37 is unlocked by worker #1 and locked by worker #37, therefore it’s locked
• box #38 is unlocked by workers #1 and #19, and locked by workers #2 and #38, therefore it’s locked
• box #39 is unlocked by workers #1 and #13, and locked by workers #3 and #39, therefore it’s locked
• box #40 is unlocked by workers #1, #4, #8 and #20, and locked by workers #2, #5, #10 and #40, therefore it’s locked
• box #41 is unlocked by worker #1 and locked by worker #41, therefore it’s locked
• box #42 is unlocked by workers #1, #3, #7 and #21, and locked by workers #2, #6, #14 and #42, therefore it’s locked
• box #43 is unlocked by worker #1 and locked by worker #43, therefore it’s locked
• box #44 is unlocked by workers #1, #4 and #22, and locked by workers #2, #11 and #44, therefore it’s locked
• box #45 is unlocked by workers #1, #5 and #15, and locked by workers #3, #9 and #45, therefore it’s locked
• box #46 is unlocked by workers #1 and #23, and locked by workers #2 and #46, therefore it’s locked
• box #47 is unlocked by worker #1 and locked by worker #47, therefore it’s locked
• box #48 is unlocked by workers #1, #3, #6, #12 and #24, and locked by workers #2, #4, #8, #16 and #48, therefore it’s locked
• box #49 is unlocked by workers #1 and #49, and locked by worker #7, therefore it’s unlocked
• box #50 is unlocked by workers #1, #5 and #25, and locked by workers #2, #10 and #50, therefore it’s locked
• box #51 is unlocked by workers #1 and #17, and locked by workers #3 and #51, therefore it’s locked
• box #52 is unlocked by workers #1, #4 and #26, and locked by workers #2, #13 and #52, therefore it’s locked
• box #53 is unlocked by worker #1 and locked by worker #53, therefore it’s locked
• box #54 is unlocked by workers #1, #3, #9 and #27, and locked by workers #2, #6, #18 and #54, therefore it’s locked
• box #55 is unlocked by workers #1 and #11, and locked by workers #5 and #55, therefore it’s locked
• box #56 is unlocked by workers #1, #4, #8 and #28, and locked by workers #2, #7, #14 and #56, therefore it’s locked
• box #57 is unlocked by workers #1 and #19, and locked by workers #3 and #57, therefore it’s locked
• box #58 is unlocked by workers #1 and #29, and locked by workers #2 and #58, therefore it’s locked
• box #59 is unlocked by worker #1 and locked by worker #59, therefore it’s locked
• box #60 is unlocked by workers #1, #3, #5, #10, #15 and #30, and locked by workers #2, #4, #6, #12, #20 and #60, therefore it’s locked
• box #61 is unlocked by worker #1 and locked by worker #61, therefore it’s locked
• box #62 is unlocked by workers #1 and #31, and locked by workers #2 and #62, therefore it’s locked
• box #63 is unlocked by workers #1, #7 and #21, and locked by workers #3, #9 and #63, therefore it’s locked
• box #64 is unlocked by workers #1, #4, #16 and #64, and locked by workers #2, #8 and #32, therefore it’s unlocked
• box #65 is unlocked by workers #1 and #13, and locked by workers #5 and #65, therefore it’s locked
• box #66 is unlocked by workers #1, #3, #11 and #33, and locked by workers #2, #6, #22 and #66, therefore it’s locked
• box #67 is unlocked by worker #1 and locked by worker #67, therefore it’s locked
• box #68 is unlocked by workers #1, #4 and #34, and locked by workers #2, #17 and #68, therefore it’s locked
• box #69 is unlocked by workers #1 and #23, and locked by workers #3 and #69, therefore it’s locked
• box #70 is unlocked by workers #1, #5, #10 and #35, and locked by workers #2, #7, #14 and #70, therefore it’s locked
• box #71 is unlocked by worker #1 and locked by worker #71, therefore it’s locked
• box #72 is unlocked by workers #1, #3, #6, #9, #18 and #36, and locked by workers #2, #4, #8, #12, #24 and #72, therefore it’s locked
• box #73 is unlocked by worker #1 and locked by worker #73, therefore it’s locked
• box #74 is unlocked by workers #1 and #37, and locked by workers #2 and #74, therefore it’s locked
• box #75 is unlocked by workers #1, #5 and #25, and locked by workers #3, #15 and #75, therefore it’s locked
• box #76 is unlocked by workers #1, #4 and #38, and locked by workers #2, #19 and #76, therefore it’s locked
• box #77 is unlocked by workers #1 and #11, and locked by workers #7 and #77, therefore it’s locked
• box #78 is unlocked by workers #1, #3, #13 and #39, and locked by workers #2, #6, #26 and #78, therefore it’s locked
• box #79 is unlocked by worker #1 and locked by worker #79, therefore it’s locked
• box #80 is unlocked by workers #1, #4, #8, #16 and #40, and locked by workers #2, #5, #10, #20 and #80, therefore it’s locked
• box #81 is unlocked by workers #1, #9 and #81, and locked by workers #3 and #27, therefore it’s unlocked
• box #82 is unlocked by workers #1 and #41, and locked by workers #2 and #82, therefore it’s locked
• box #83 is unlocked by worker #1 and locked by worker #83, therefore it’s locked
• box #84 is unlocked by workers #1, #3, #6, #12, #21 and #42, and locked by workers #2, #4, #7, #14, #28 and #84, therefore it’s locked
• box #85 is unlocked by workers #1 and #17, and locked by workers #5 and #85, therefore it’s locked
• box #86 is unlocked by workers #1 and #43, and locked by workers #2 and #86, therefore it’s locked
• box #87 is unlocked by workers #1 and #29, and locked by workers #3 and #87, therefore it’s locked
• box #88 is unlocked by workers #1, #4, #11 and #44, and locked by workers #2, #8, #22 and #88, therefore it’s locked
• box #89 is unlocked by worker #1 and locked by worker #89, therefore it’s locked
• box #90 is unlocked by workers #1, #3, #6, #10, #18 and #45, and locked by workers #2, #5, #9, #15, #30 and #90, therefore it’s locked
• box #91 is unlocked by workers #1 and #13, and locked by workers #7 and #91, therefore it’s locked
• box #92 is unlocked by workers #1, #4 and #46, and locked by workers #2, #23 and #92, therefore it’s locked
• box #93 is unlocked by workers #1 and #31, and locked by workers #3 and #93, therefore it’s locked
• box #94 is unlocked by workers #1 and #47, and locked by workers #2 and #94, therefore it’s locked
• box #95 is unlocked by workers #1 and #19, and locked by workers #5 and #95, therefore it’s locked
• box #96 is unlocked by workers #1, #3, #6, #12, #24 and #48, and locked by workers #2, #4, #8, #16, #32 and #96, therefore it’s locked
• box #97 is unlocked by worker #1 and locked by worker #97, therefore it’s locked
• box #98 is unlocked by workers #1, #7 and #49, and locked by workers #2, #14 and #98, therefore it’s locked
• box #99 is unlocked by workers #1, #9 and #33, and locked by workers #3, #11 and #99, therefore it’s locked
• box #100 is unlocked by workers #1, #4, #10, #25 and #100, and locked by workers #2, #5, #20 and #50, therefore it’s unlocked

Piles of Prime Pairs

A087641 Start of the first sequence of exactly n consecutive pairs of twin primes

29, 101, 5, 9419, 909287, 325267931, 678771479, 1107819732821, 170669145704411, 3324648277099157, 789795449254776509

Example: a(6)=325267931 is the starting point of the first occurrence of 6 consecutive pairs of twin primes: (325267931 325267933) (325267937 325267939) (325267949 325267951) (325267961 325267963) (325267979 325267981) (325267991 325267993).

A087641 at the Encyclopedia of Integer Sequences

Abounding in Abundants

This is the famous Ulam spiral, invented by the Jewish mathematician Stanisław Ulam (pronounced OO-lam) to represent prime numbers on a square grid:

The Ulam spiral of prime numbers


The red square represents 1, with 2 as the white block immediately to its right and 3 immediately above 2. Then 5 is the white block one space to the left of 3 and 7 the white block one space below 5. Then 11 is the white block right beside 2 and 13 the white block one space above 11. And so on. The primes aren’t regularly spaced on the spiral but patterns are nevertheless appearing. Here’s the Ulam spiral at higher resolutions:

The Ulam spiral x2


The Ulam spiral x4


The primes are neither regular nor random in their distribution on the spiral. They stand tantalizingly betwixt and between. So the numbers represented on this Ulam-like spiral, which looks like an aerial view of a city designed by architects who occasionally get drunk:

Ulam-like spiral of abundant numbers


The distribution of abundant numbers is much more regular than the primes, but is far from wholly predictable. And what are abundant numbers? They’re numbers n such that sum(divisors(n)-n) > n. In other words, when you add the divisors of n less than n, the sum is greater than n. The first abundant number is 12:

12 is divisible by 1, 2, 3, 4, 6 → 1 + 2 + 3 + 4 + 6 = 16 > 12

The abundant numbers go like this:

12, 18, 20, 24, 30, 36, 40, 42, 48, 54, 56, 60, 66, 70, 72, 78, 80, 84, 88, 90, 96, 100, 102, 104, 108, 112, 114, 120, 126, 132, 138, 140, 144, 150, 156, 160, 162, 168, 174, 176, 180, 186, 192, 196, 198, 200, 204, 208, 210, 216, 220, 222, 224, 228, 234, 240, 246, 252, 258, 260, 264, 270… — A005101 at the Online Encyclopedia of Integer Sequences

Are all abundant numbers even? No, but the first odd abundant number takes a long time to arrive: it’s 45045. The abundance of 45045 was first discovered by the French mathematician Charles de Bovelles or Carolus Bovillus (c. 1475-1566), according to David Wells in his wonderful Penguin Dictionary of Curious and Interesting Numbers (1986):

45045 = 3^2 * 5 * 7 * 11 * 13 → 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 21 + 33 + 35 + 39 + 45 + 55 + 63 + 65 + 77 + 91 + 99 + 105 + 117 + 143 + 165 + 195 + 231 + 273 + 315 + 385 + 429 + 455 + 495 + 585 + 693 + 715 + 819 + 1001 + 1155 + 1287 + 1365 + 2145 + 3003 + 3465 + 4095 + 5005 + 6435 + 9009 + 15015 = 59787 > 45045

Here’s the spiral of abundant numbers at higher resolutions:

Abundant numbers x2


Abundant numbers x4


Negating the spiral of the abundant numbers — almost — is the spiral of the deficient numbers, where sum(divisors(n)-n) < n. Like most odd numbers, 15 is deficient:

15 = 3 * 5 → 1 + 3 + 5 = 9 < 15

Here’s the spiral of deficient numbers at various resolutions:

Deficient numbers on Ulam-like spiral


Deficient numbers x2


Deficient numbers x4


The spiral of deficient numbers doesn’t quite negate (reverse the colors of) the spiral of abundant numbers because of the very rare perfect numbers, where sum(divisors(n)-n) = n. That is, their factor-sums are exactly equal to themselves:

• 6 = 2 * 3 → 1 + 2 + 3 = 6
• 28 = 2^2 * 7 → 1 + 2 + 4 + 7 + 14 = 28
• 496 = 2^4 * 31 → 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248 = 496

Now let’s try numbers n such than sum(divisors(n)) mod 2 = 1 (“n mod 2″ gives the remainder when n is divided by 2, i.e. n mod 2 is either 0 or 1). For example:

• 4 = 2^2 → 1 + 2 + 4 = 7 → 7 mod 2 = 1
• 18 = 2 * 3^2 → 1 + 2 + 3 + 6 + 9 + 18 = 39 → 39 mod 2 = 1
• 72 = 2^3 * 3^2 → 1 + 2 + 3 + 4 + 6 + 8 + 9 + 12 + 18 + 24 + 36 + 72 = 195 → 195 mod 2 = 1

Here are spirals for these numbers:

Ulam-like spiral for n such than sum(divisors(n)) mod 2 = 1


sum(divisors(n)) mod 2 = 1 x2


sum(divisors(n)) mod 2 = 1 x4


sum(divisors(n)) mod 2 = 1 x8


sum(divisors(n)) mod 2 = 1 x16


Summer Samer

10 can be represented in exactly 10 ways as a sum of distinct integers:


10 = 1 + 2 + 3 + 4
10 = 2 + 3 + 5
10 = 1 + 4 + 5
10 = 1 + 3 + 6
10 = 4 + 6 (c=5)
10 = 1 + 2 + 7
10 = 3 + 7
10 = 2 + 8
10 = 1 + 9
10 = 10 (c=10)

But there’s something unsatisfying about including 10 as a sum of itself. It’s much more satisfying that 76 can be represented in exactly 76 ways as a sum of distinct primes:


76 = 2 + 3 + 7 + 11 + 13 + 17 + 23
76 = 5 + 7 + 11 + 13 + 17 + 23
76 = 2 + 3 + 5 + 11 + 13 + 19 + 23
76 = 3 + 7 + 11 + 13 + 19 + 23
76 = 2 + 3 + 5 + 7 + 17 + 19 + 23 (c=5)
76 = 2 + 3 + 5 + 7 + 13 + 17 + 29
76 = 2 + 3 + 5 + 7 + 11 + 19 + 29
76 = 3 + 5 + 7 + 13 + 19 + 29
76 = 11 + 17 + 19 + 29
76 = 11 + 13 + 23 + 29 (c=10)
76 = 2 + 5 + 17 + 23 + 29
76 = 7 + 17 + 23 + 29
76 = 2 + 3 + 19 + 23 + 29
76 = 5 + 19 + 23 + 29
76 = 2 + 3 + 5 + 7 + 11 + 17 + 31 (c=15)
76 = 3 + 5 + 7 + 13 + 17 + 31
76 = 3 + 5 + 7 + 11 + 19 + 31
76 = 2 + 11 + 13 + 19 + 31
76 = 2 + 7 + 17 + 19 + 31
76 = 2 + 7 + 13 + 23 + 31 (c=20)
76 = 2 + 3 + 17 + 23 + 31
76 = 5 + 17 + 23 + 31
76 = 3 + 19 + 23 + 31
76 = 2 + 3 + 11 + 29 + 31
76 = 5 + 11 + 29 + 31 (c=25)
76 = 3 + 13 + 29 + 31
76 = 3 + 5 + 7 + 11 + 13 + 37
76 = 2 + 7 + 13 + 17 + 37
76 = 2 + 7 + 11 + 19 + 37
76 = 2 + 5 + 13 + 19 + 37 (c=30)
76 = 7 + 13 + 19 + 37
76 = 3 + 17 + 19 + 37
76 = 2 + 3 + 11 + 23 + 37
76 = 5 + 11 + 23 + 37
76 = 3 + 13 + 23 + 37 (c=35)
76 = 2 + 3 + 5 + 29 + 37
76 = 3 + 7 + 29 + 37
76 = 3 + 5 + 31 + 37
76 = 2 + 5 + 11 + 17 + 41
76 = 7 + 11 + 17 + 41 (c=40)
76 = 2 + 3 + 13 + 17 + 41
76 = 5 + 13 + 17 + 41
76 = 2 + 3 + 11 + 19 + 41
76 = 5 + 11 + 19 + 41
76 = 3 + 13 + 19 + 41 (c=45)
76 = 2 + 3 + 7 + 23 + 41
76 = 5 + 7 + 23 + 41
76 = 2 + 7 + 11 + 13 + 43
76 = 2 + 3 + 11 + 17 + 43
76 = 5 + 11 + 17 + 43 (c=50)
76 = 3 + 13 + 17 + 43
76 = 2 + 5 + 7 + 19 + 43
76 = 3 + 11 + 19 + 43
76 = 2 + 3 + 5 + 23 + 43
76 = 3 + 7 + 23 + 43 (c=55)
76 = 2 + 31 + 43
76 = 2 + 3 + 11 + 13 + 47
76 = 5 + 11 + 13 + 47
76 = 2 + 3 + 7 + 17 + 47
76 = 5 + 7 + 17 + 47 (c=60)
76 = 2 + 3 + 5 + 19 + 47
76 = 3 + 7 + 19 + 47
76 = 29 + 47
76 = 2 + 3 + 7 + 11 + 53
76 = 5 + 7 + 11 + 53 (c=65)
76 = 2 + 3 + 5 + 13 + 53
76 = 3 + 7 + 13 + 53
76 = 23 + 53
76 = 2 + 3 + 5 + 7 + 59
76 = 17 + 59 (c=70)
76 = 3 + 5 + 7 + 61
76 = 2 + 13 + 61
76 = 2 + 7 + 67
76 = 2 + 3 + 71
76 = 5 + 71 (c=75)
76 = 3 + 73

Power Flip

12 is an interesting number in a lot of ways. Here’s one way I haven’t seen mentioned before:

12 = 3^1 * 2^2


The digits of 12 represent the powers of the primes in its factorization, if primes are represented from right-to-left, like this: …7, 5, 3, 2. But I couldn’t find any more numbers like that in base 10, so I tried a power flip, from right-left to left-right. If the digits from left-to-right represent the primes in the order 2, 3, 5, 7…, then this number is has prime-power digits too:

81312000 = 2^8 * 3^1 * 5^3 * 7^1 * 11^2 * 13^0 * 17^0 * 19^0


Or, more simply, given that n^0 = 1:

81312000 = 2^8 * 3^1 * 5^3 * 7^1 * 11^2


I haven’t found any more left-to-right prime-power digital numbers in base 10, but there are more in other bases. Base 5 yields at least three (I’ve ignored numbers with just two digits in a particular base):

110 in b2 = 2^1 * 3^1 (n=6)
130 in b6 = 2^1 * 3^3 (n=54)
1010 in b2 = 2^1 * 3^0 * 5^1 (n=10)
101 in b3 = 2^1 * 3^0 * 5^1 (n=10)
202 in b7 = 2^2 * 3^0 * 5^2 (n=100)
3020 in b4 = 2^3 * 3^0 * 5^2 (n=200)
330 in b8 = 2^3 * 3^3 (n=216)
13310 in b14 = 2^1 * 3^3 * 5^3 * 7^1 (n=47250)
3032000 in b5 = 2^3 * 3^0 * 5^3 * 7^2 (n=49000)
21302000 in b5 = 2^2 * 3^1 * 5^3 * 7^0 * 11^2 (n=181500)
7810000 in b9 = 2^7 * 3^8 * 5^1 (n=4199040)
81312000 in b10 = 2^8 * 3^1 * 5^3 * 7^1 * 11^2


Post-Performative Post-Scriptum

When I searched for 81312000 at the Online Encyclopedia of Integer Sequences, I discovered that these are Meertens numbers, defined at A246532 as the “base n Godel encoding of x [namely,] 2^d(1) * 3^d(2) * … * prime(k)^d(k), where d(1)d(2)…d(k) is the base n representation of x.”

Square Pairs

Girard knew and Fermat a few years later proved the beautiful theorem that every prime of the form 4n + 1; that is, the primes 5, 13, 17, 29, 37, 41, 53… is the sum of two squares in exactly one way. Primes of the form 4n + 3, such as 3, 7, 11, 19, 23, 31, 43, 47… are never the sum of two squares. — David Wells, The Penguin Dictionary of Curious and Interesting Numbers (1986), entry for “13”.


Elsewhere other-accessible…

Fermat’s theorem on sums of two squares
Pythagorean primes

Primal Stream

It’s obvious when you think about: an even number can never be the sum of two consecutive integers. Conversely, an odd number (except 1) is always the sum of two consecutive integers: 3 = 1 + 2; 5 = 2 + 3; 7 = 3 + 4; 9 = 4 + 5; and so on. The sum of three consecutive integers can be either odd or even: 6 = 1 + 2 + 3; 9 = 2 + 3 + 4. The sum of four consecutive integers must always be even: 1 + 2 + 3 + 4 = 10; 2 + 3 + 4 + 5 = 14. And so on.

But notice that 9 is the sum of consecutive integers in two different ways: 9 = 4 + 5 = 2 + 3 + 4. Having spotted that, I decided to look for numbers that were the sums of consecutive integers in the most different ways. These are the first few:

3 = 1 + 2 (number of sums = 1)
9 = 2 + 3 + 4 = 4 + 5 (s = 2)
15 = 1 + 2 + 3 + 4 + 5 = 4 + 5 + 6 = 8 + 7 = (s = 3)
45 (s = 5)
105 (s = 7)
225 (s = 8)
315 (s = 11)
945 (s = 15)
1575 (s = 17)
2835 (s = 19)
3465 (s = 23)
10395 (s = 31)


It was interesting that the number of different consecutive-integer sums for n was most often a prime number. Next I looked for the sequence at the Online Encyclopedia of Integer Sequences and discovered something that I hadn’t suspected:

A053624 Highly composite odd numbers: where d(n) increases to a record.

1, 3, 9, 15, 45, 105, 225, 315, 945, 1575, 2835, 3465, 10395, 17325, 31185, 45045, 121275, 135135, 225225, 405405, 675675, 1576575, 2027025, 2297295, 3828825, 6891885, 11486475, 26801775, 34459425, 43648605, 72747675, 130945815 — A053624 at OEIS

The notes add that the sequence is “Also least number k such that the number of partitions of k into consecutive integers is a record. For example, 45 = 22+23 = 14+15+16 = 7+8+9+10+11 = 5+6+7+8+9+10 = 1+2+3+4+5+6+7+8+9, six such partitions, but all smaller terms have fewer such partitions (15 has four).” When you don’t count the number n itself as a partition of n, you get 3 partitions for 15, i.e. consecutive integers sum to 15 in 3 different ways, so s = 3. I looked at more values for s and found that the stream of primes continued to flow:

3 → s = 1
9 = 3^2 → s = 2 (prime)
15 = 3 * 5 → s = 3 (prime)
45 = 3^2 * 5 → s = 5 (prime)
105 = 3 * 5 * 7 → s = 7 (prime)
225 = 3^2 * 5^2 → s = 8 = 2^3
315 = 3^2 * 5 * 7 → s = 11 (prime)
945 = 3^3 * 5 * 7 → s = 15 = 3 * 5
1575 = 3^2 * 5^2 * 7 → s = 17 (prime)
2835 = 3^4 * 5 * 7 → s = 19 (prime)
3465 = 3^2 * 5 * 7 * 11 → s = 23 (prime)
10395 = 3^3 * 5 * 7 * 11 → s = 31 (prime)
17325 = 3^2 * 5^2 * 7 * 11 → s = 35 = 5 * 7
31185 = 3^4 * 5 * 7 * 11 → s = 39 = 3 * 13
45045 = 3^2 * 5 * 7 * 11 * 13 → s = 47 (prime)
121275 = 3^2 * 5^2 * 7^2 * 11 → s = 53 (prime)
135135 = 3^3 * 5 * 7 * 11 * 13 → s = 63 = 3^2 * 7
225225 = 3^2 * 5^2 * 7 * 11 * 13 → s = 71 (prime)
405405 = 3^4 * 5 * 7 * 11 * 13 → s = 79 (prime)
675675 = 3^3 * 5^2 * 7 * 11 * 13 → s = 95 = 5 * 19
1576575 = 3^2 * 5^2 * 7^2 * 11 * 13 → s = 107 (prime)
2027025 = 3^4 * 5^2 * 7 * 11 * 13 → s = 119 = 7 * 17
2297295 = 3^3 * 5 * 7 * 11 * 13 * 17 → s = 127 (prime)
3828825 = 3^2 * 5^2 * 7 * 11 * 13 * 17 → s = 143 = 11 * 13
6891885 = 3^4 * 5 * 7 * 11 * 13 * 17 → s = 159 = 3 * 53
11486475 = 3^3 * 5^2 * 7 * 11 * 13 * 17 → s = 191 (prime)
26801775 = 3^2 * 5^2 * 7^2 * 11 * 13 * 17 → s = 215 = 5 * 43
34459425 = 3^4 * 5^2 * 7 * 11 * 13 * 17 → s = 239 (prime)
43648605 = 3^3 * 5 * 7 * 11 * 13 * 17 * 19 → s = 255 = 3 * 5 * 17
72747675 = 3^2 * 5^2 * 7 * 11 * 13 * 17 * 19 → s = 287 = 7 * 41
130945815 = 3^4 * 5 * 7 * 11 * 13 * 17 * 19 → s = 319 = 11 * 29


I can’t spot any way of predicting when n will yield a primal s, but I like the way that a simple question took an unexpected turn. When a number sets a record for the number of different ways it can be the sum of consecutive integers, that number will also be a highly composite odd number.