Jewel Tree

Dual tree for Farey tessellation and positive Farey tree (from ResearchGate)


• Die Geometrie besitzt zwei große Schätze: einer ist der Satz von Pythagoras, der andere die Teilung einer Strecke nach dem äußeren und mittleren Verhältnis. Den ersten dürfen wir mit einem Scheffel Gold vergleichen; den zweiten nennen wir ein kostbares Juwel. — Johannes Kepler

• “Geometry has two great treasures: one is the Theorem of Phythagoras, the other the division of a line in extreme and mean ratio. The first we can compare to a mass of gold; the other we may call a precious jewel.”

ResidUlam

Seq’ and ye shall find. So what’s the next number in this sequence?

1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 11, 3, 13, 7, 15, 1, 17, 9, 19, ?


It’s simple once you’ve spotted the rule. List the counting numbers. If a number is a multiple of 2, divide it by 2 until it’s no longer a multiple of 2 and it becomes what I call a 2-residue. Like this:

reduce(2,n) = 1, 2 → 1, 3, 4 → 2 → 1, 5, 6 → 3, 7, 8 → 4 → 2 → 1, 9, 10 → 5, 11, 12 → 6 → 3, 13, 14 → 7, 15, 16 → 8 → 4 → 2 → 1, 17, 18 → 9, 19, 20 → 10 → 5... — A000265 at the Online Encyclopedia of Integer Sequences (OEIS)


So the next number was 5. Now, what’s the next number in this sequence?

1, 2, 1, 4, 5, 2, 7, 8, 1, 10, 11, 4, 13, 14, 5, 16, 17, 2, 19, 20, ?


The rule now is: divide multiples of 3 by 3 until they’re no longer multiples of 3.

reduce(3,n) = 1, 2, 1, 4, 5, 2, 7, 8, 1, 10, 11, 4, 13, 14, 5, 16, 17, 2, 19, 20, 7, 22, 23, 8, 25, 26, 1, 28, 29, 10, 31, 32, 11, 34, 35, 4, 37, 38, 13, 40, 41, 14, 43, 44, 5, 46, 47, 16, 49, 50, 17, 52, 53, 2, 55, 56, 19, 58, 59, 20, 61, 62, 7, 64, 65, 22, 67, 68, 23, 70, 71, 8, 73, 74, 25, 76, ... — A038502 at OEIS


So the next number is 7, the 3-residue of 21. After looking at these sequences, I did what I usually did and tried them on an Ulam spiral. The sum of reduce(2,n) is this:

1, 2, 5, 6, 11, 14, 21, 22, 31, 36, 47, 50, 63, 70, 85, 86, 103, 112, 131, 136, 157, 168, 191, 194, 219, 232, 259, 266, 295, 310, 341, 342, 375, 392, 427, 436, 473, 492, 531, 536, 577, 598, 641, 652, 697, 720, 767, 770, 819, 844, 895, 908, 961, 988, 1043, 1050, 1107, 1136, 1195, 1210, 1271, 1302, 1365, 1366, 1431, 1464, 1531, 1548, 1617, 1652, 1723, 1732, 1805, 1842, 1917, 1936, 2013, 2052, 2131, 2136, 2217, 2258, 2341, 2362, 2447, 2490, 2577, 2588, 2677, 2722, 2813, 2836, 2929, 2976... — A135013 at OEIS


And on an Ulam spiral, the sequence looks like this:

Ulam-like spiral for sum(reduce(2,n)) = 1, 2, 5, 6, 11, 14, 21, 22, 31, 36, 47…


Here are more ResidUlam spirals (not all at the same resolution):

Spiral for sum(reduce(3,n))


Spiral for sum(reduce(4,n))


Spiral for sum(reduce(10,n))


Spiral for sum(reduce(11,n))


Spiral for sum(reduce(18,n))


Spiral for sum(reduce(28,n))


Spiral for sum(reduce(51,n))


N.B. THe 51-ResidUlam doesn’t look like that because the numbers are thinning, but because sum(reduce(51,n)) concentrates them in certain parts of the spiral. Compare sum(reduce(64,n)):

Spiral for sum(reduce(64,n))


Next, you can try reducing numbers with more than one multiple. For example, if you reduce the counting numbers by 2 and 3, you get this sequence:

reduce(2,3,n) = 1, 1, 1, 1, 5, 1, 7, 1, 1, 5, 11, 1, 13, 7, 5, 1, 17, 1, 19, 5, 7, 11, 23, 1, 25, 13, 1, 7, 29, 5, 31, 1, 11, 17, 35, 1, 37, 19, 13, 5, 41, 7, 43, 11, 5, 23, 47, 1, 49, 25, 17, 13, 53, 1, 55, 7, 19, 29, 59, 5, 61, 31, 7, 1, 65, 11, 67, 17, 23, 35, 71, 1, 73, 37, 25, 19, 77, 13, 79, 5, 1, ... — A065330 at OEIS


sum(reduce(2,3,n)) = 1, 2, 3, 4, 9, 10, 17, 18, 19, 24, 35, 36, 49, 56, 61, 62, 79, 80, 99, 104, 111, 122, 145, 146, 171, 184, 185, 192, 221, 226, 257, ...


On an ResiduUlam spiral, sum(reduce(2,3,n)) looks like this at higher and higher resolution:

Spiral for sum(reduce(2,3,n)) #1


Spiral for sum(reduce(2,3,n)) #2


Spiral for sum(reduce(2,3,n)) #3


Spiral for sum(reduce(2,3,n)) #4


Now try another double-reducer:

reduce(6,3,n) = 1, 2, 1, 4, 5, 1, 7, 8, 1, 10, 11, 2, 13, 14, 5, 16, 17, 1, 19, 20, 7, 22, 23, 4, 25, 26, 1, 28, 29, 5, 31, 32, 11, 34, 35, 1, 37, 38, 13, 40, 41, 7, 43, 44, 5, 46, 47, 8, 49, 50, 17, 52, 53, 1, 55, 56, 19, 58, 59, 10, 61, 62, 7, 64, 65, 11, 67, 68, 23, ...


sum(reduce(6,3,n)) = 1, 3, 4, 8, 13, 20, 28, 29, 39, 50, 52, 65, 79, ...


Note that it’s important to reduce by 6 before reducing by 3 (reducing by 3 first would mean no numbers to reduce by 6). Here’s the ResidUlam spiral:

Spiral for sum(reduce(6,3,n)) #1


Spiral for sum(reduce(6,3,n)) #2


Spiral for sum(reduce(6,3,n)) #3


Spiral for sum(reduce(6,3,n)) #4


And two more double-multiple ResidUlams:

Spiral for sum(reduce(7,3,n))


Spiral for sum(reduce(10,8,n))


Mathematicoynte

Pre-previously, I looked at a fractal phallus. Now I want to look at a fractal fanny (in the older British sense). In fact, it’s a fractional fractal fanny. Take a look at these fractions:


1/10, 1/9, 1/8, 1/7, 1/6, 1/5, 2/10, 2/9, 1/4, 2/8, 2/7, 3/10, 1/3, 2/6, 3/9, 3/8, 2/5, 4/10, 3/7, 4/9, 1/2, 2/4, 3/6, 4/8, 5/10, 5/9, 4/7, 3/5, 6/10, 5/8, 2/3, 4/6, 6/9, 7/10, 5/7, 3/4, 6/8, 7/9, 4/5, 8/10, 5/6, 6/7, 7/8, 8/9, 9/10

They’re all the fractions for 1/2..(n-1)/n, n = 10, sorted by increasing size. But obviously some of them are the same: 1/2 = 2/4 = 3/6 = 5/10, 1/3 = 2/6 = 3/9, 1/4 = 2/8, and so on. If you remove the duplicates, you get this set of reduced fractions:


1/10, 1/9, 1/8, 1/7, 1/6, 1/5, 2/9, 1/4, 2/7, 3/10, 1/3, 3/8, 2/5, 3/7, 4/9, 1/2, 5/9, 4/7, 3/5, 5/8, 2/3, 7/10, 5/7, 3/4, 7/9, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10

Now here are the reduced fractions for 1/2..(n-1)/n, n = 30:


1/30, 1/29, 1/28, 1/27, 1/26, 1/25, 1/24, 1/23, 1/22, 1/21, 1/20, 1/19, 1/18, 1/17, 1/16, 1/15, 2/29, 1/14, 2/27, 1/13, 2/25, 1/12, 2/23, 1/11, 2/21, 1/10, 3/29, 2/19, 3/28, 1/9, 3/26, 2/17, 3/25, 1/8, 3/23, 2/15, 3/22, 4/29, 1/7, 4/27, 3/20, 2/13, 3/19, 4/25, 1/6, 5/29, 4/23, 3/17, 5/28, 2/11, 5/27, 3/16, 4/21, 5/26, 1/5, 6/29, 5/24, 4/19, 3/14, 5/23, 2/9, 5/22, 3/13, 7/30, 4/17, 5/21, 6/25, 7/29, 1/4, 7/27, 6/23, 5/19, 4/15, 7/26, 3/11, 8/29, 5/18, 7/25, 2/7, 7/24, 5/17, 8/27, 3/10, 7/23, 4/13, 9/29, 5/16, 6/19, 7/22, 8/25, 9/28, 1/3, 10/29, 9/26, 8/23, 7/20, 6/17, 5/14, 9/25, 4/11, 11/30, 7/19, 10/27, 3/8, 11/29, 8/21, 5/13, 7/18, 9/23, 11/28, 2/5, 11/27, 9/22, 7/17, 12/29, 5/12, 8/19, 11/26, 3/7, 13/30, 10/23, 7/16, 11/25, 4/9, 13/29, 9/20, 5/11, 11/24, 6/13, 13/28, 7/15, 8/17, 9/19, 10/21, 11/23, 12/25, 13/27, 14/29, 1/2, 15/29, 14/27, 13/25, 12/23, 11/21, 10/19, 9/17, 8/15, 15/28, 7/13, 13/24, 6/11, 11/20, 16/29, 5/9, 14/25, 9/16, 13/23, 17/30, 4/7, 15/26, 11/19, 7/12, 17/29, 10/17, 13/22, 16/27, 3/5, 17/28, 14/23, 11/18, 8/13, 13/21, 18/29, 5/8, 17/27, 12/19, 19/30, 7/11, 16/25, 9/14, 11/17, 13/20, 15/23, 17/26, 19/29, 2/3, 19/28, 17/25, 15/22, 13/19, 11/16, 20/29, 9/13, 16/23, 7/10, 19/27, 12/17, 17/24, 5/7, 18/25, 13/18, 21/29, 8/11, 19/26, 11/15, 14/19, 17/23, 20/27, 3/4, 22/29, 19/25, 16/21, 13/17, 23/30, 10/13, 17/22, 7/9, 18/23, 11/14, 15/19, 19/24, 23/29, 4/5, 21/26, 17/21, 13/16, 22/27, 9/11, 23/28, 14/17, 19/23, 24/29, 5/6, 21/25, 16/19, 11/13, 17/20, 23/27, 6/7, 25/29, 19/22, 13/15, 20/23, 7/8, 22/25, 15/17, 23/26, 8/9, 25/28, 17/19, 26/29, 9/10, 19/21, 10/11, 21/23, 11/12, 23/25, 12/13, 25/27, 13/14, 27/29, 14/15, 15/16, 16/17, 17/18, 18/19, 19/20, 20/21, 21/22, 22/23, 23/24, 24/25, 25/26, 26/27, 27/28, 28/29, 29/30

Can you see the fractal fanny? Not unless you’re superhuman. But any normal human can see the fractal fanny when you turn those reduced and sorted fractions, a/b, into a graph, where y = b and x = n for a/bn:

graph for b of reduced a/b = 1/2..29/30, sorted by size of a/b

(click for larger)


If you don’t reduce the fractions, you get this distorted coynte:

graph for b of all fractions 1/2..29/30, sorted by a/b


And you can use other variables for y, like the sum of the continued fraction of a/b:

graph for sum(contfrac(a/b)) of reduced fractions 1/2..29/30, sorted by a/b


graph for cfsum of all fractions 1/2..29/30, sorted by a/b


And the product of the continued fraction of a/b:

graph for prod(contfrac(a/b)) of reduced fractions 1/2..29/30, sorted by a/b


graph for cfmul of all fractions 1/2..29/30, sorted by a/b


And you can sort by the size of other variables, like the number of factors of b:

graph for a+b of all fractions 1/2..29/30, sorted by factornum(b)


And so on:

graph for a of reduced fractions 1/2..29/30, sorted by a/b


graph for a of reduced fractions 1/2..29/30, sorted by a/b


graph for a of all fractions 1/2..29/30, sorted by a/b


graph for a of all fractions 1/2..29/30, sorted by length(contfrac(a/b))


graph for a of all fractions 1/2..29/30, sorted by factornum(b)


graph for a of all fractions 1/2..29/30, sorted by gcd(a/b)


graph for a+b of all fractions 1/2..29/30, sorted by a/b


graph for a+b of reduced fractions 1/2..29/30, sorted by a/b


graph for a+b of all fractions 1/2..29/30, sorted by a+b


graph for a+b of all fractions 1/2..29/30, sorted by cflen(a/b)


graph for a+b of all fractions 1/2..29/30, sorted by gbd(a,b)


graph for b of all fractions 1/2..29/30, sorted by a+b


graph for b of all fractions 1/2..29/30, sorted by cflen(a/b)


graph for b of all fractions 1/2..29/30, sorted by factnum(b)


graph for b of all fractions 1/2..29/30, sorted by gcd(a,b)


graph for b-a of all fractions 1/2..29/30, sorted by a/b


graph for b-a of reduced fractions 1/2..29/30, sorted by a/b


graph for b-a of all fractions 1/2..29/30, sorted by a+b


graph for b-a of all fractions 1/2..29/30, sorted by factnum(b)


graph for cfmul of all fractions 1/2..29/30, sorted by a


graph for cfsum of all fractions 1/2..29/30, sorted by a


Previously Pre-Posted (Please Peruse)

Phrallic Frolics — a look at fractal phalluses, a.k.a. phralluses

The Call of CFulhu

“The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents.” So said HPL in “The Call of Cthulhu” (1926). But I’d still like to correlate the contents of mine a bit better. For example, I knew that φ, the golden ratio, is the most irrational of all numbers, in that it is the slowest to be approximated with rational fractions. And I also knew that continued fractions, or CFs, were a way of representing both rationals and irrationals as a string of numbers, like this:

contfrac(10/7) = [1; 2, 3]
10/7 = 1 + 1/(2 + 1/3)
10/7 = 1.428571428571…

contfrac(3/5) = [0; 1, 1, 2]
4/5 = 0 + 1/(1 + 1/(1 + 1/2))
4/5 = 0.8

contfrac(11/8) = [1; 2, 1, 2]
11/8 = 1 + 1/(2 + 1/(1 + 1/2))
11/8 = 1.375

contfrac(4/7) = [0; 1, 1, 3]
4/7 = 0 + 1/(1 + 1/(1 + 1/3))
4/7 = 0.57142857142…

contfrac(17/19) = [0; 1, 8, 2]
17/19 = 0 + 1/(1 + 1/(8 + 1/2))
17/19 = 0.8947368421052…

contfrac(8/25) = [0; 3, 8]
8/25 = 0 + 1/(3 + 1/8)
8/25 = 0.32

contfrac(√2) = [1; 2, 2, 2, 2, 2, 2, 2…] = [1; 2]

√2 = 1 + 1/(2 + 1/(2 + 1/(2 + 1/(2 + 1/(2 + 1/(2 + 1/2 + …))))))

√2 = 1.41421356237309504…

contfrac(φ) = [1; 1, 1, 1, 1, 1, 1, 1, 1…]

φ = 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/1 + …)))))))

φ = 1.6180339887498948…


But I didn’t correlate those two contents of my mind: the maximal irrationality of φ and the way continued fractions work.

That’s why I was surprised when I was looking at the continued fractions of 2..(n-1) / n for 3,4,5,6,7… That is, I was looking at the continued fractions of 2/3, 3/4, 2/5, 3/5, 4/5, 5/6, 2/7, 3/7… (skipping fractions like 2/4, 2/6, 3/6 etc, because they’re reducible: 2/4 = ½, 2/6 = 1/3, 3/6 = ½ etc). I wondered which fractions set successive records for the length of their continued fractions as one worked through ½, 2/3, 3/4, 2/5, 3/5, 4/5, 5/6, 2/7, 3/7… And because I hadn’t correlated the contents of my mind, I was surprised at the result. I shouldn’t have been, of course:

contfrac(1/2) = [0; 2] (cfl=1)
1/2 = 0 + 1/2
1/2 = 0.5

contfrac(2/3) = [0; 1, 2] (cfl=2)
2/3 = 0 + 1/(1 + 1/2)
2/3 = 0.666666666…

contfrac(3/5) = [0; 1, 1, 2] (cfl=3)
3/5 = 0 + 1/(1 + 1/(1 + 1/2))
3/5 = 0.6

contfrac(5/8) = [0; 1, 1, 1, 2] (cfl=4)
5/8 = 0 + 1/(1 + 1/(1 + 1/(1 + 1/2)))
5/8 = 0.625

contfrac(8/13) = [0; 1, 1, 1, 1, 2] (cfl=5)
8/13 = 0 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/2))))
8/13 = 0.615384615…

contfrac(13/21) = [0; 1, 1, 1, 1, 1, 2] (cfl=6)
13/21 = 0 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/2)))))
13/21 = 0.619047619…

contfrac(21/34) = [0; 1, 1, 1, 1, 1, 1, 2] (cfl=7)
21/34 = 0 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/2))))))
21/34 = 0.617647059…

contfrac(34/55) = [0; 1, 1, 1, 1, 1, 1, 1, 2] (cfl=8)
contfrac(55/89) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=9)
contfrac(89/144) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=10)
contfrac(144/233) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=11)
contfrac(233/377) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=12)
contfrac(377/610) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=13)
contfrac(610/987) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=14)
contfrac(987/1597) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=15)
contfrac(1597/2584) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=16)
contfrac(2584/4181) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=17)
contfrac(4181/6765) = [0; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=18)
[…]


Which n1/n2 set records for the length of their continued fractions (with n2 > n1)? It’s the successive Fibonacci fractions, fib(i)/fib(i+1), of course. I didn’t anticipate that answer because I didn’t understand φ and continued fractions properly. And I still don’t, because I’ve been surprised again today looking at palindromic CFs like these:

contfrac(2/5) = [0; 2, 2] (cfl=2)
2/5 = 0 + 1/(2 + 1/2)
2/5 = 0.4

contfrac(3/8) = [0; 2, 1, 2] (cfl=3)
3/8 = 0 + 1/(2 + 1/(1 + 1/2))
3/8 = 0.375

contfrac(3/10) = [0; 3, 3] (cfl=2)
3/10 = 0 + 1/(3 + 1/3)
3/10 = 0.3

contfrac(5/12) = [0; 2, 2, 2] (cfl=3)
5/12 = 0 + 1/(2 + 1/(2 + 1/2))
5/12 = 0.416666666…

contfrac(5/13) = [0; 2, 1, 1, 2] (cfl=4)
5/13 = 0 + 1/(2 + 1/(1 + 1/(1 + 1/2)))
5/13 = 0.384615384…

contfrac(4/15) = [0; 3, 1, 3] (cfl=3)
4/15 = 0 + 1/(3 + 1/(1 + 1/3))
4/15 = 0.266666666…

contfrac(7/16) = [0; 2, 3, 2] (cfl=3)
7/16 = 0 + 1/(2 + 1/(3 + 1/2))
7/16 = 0.4375

contfrac(4/17) = [0; 4, 4] (cfl=2)
4/17 = 0 + 1/(4 + 1/4)
4/17 = 0.235294117…


Again, I wondered which of these fractions set successive records for the length of their palindromic continued fractions. Here’s the answer:

contfrac(1/2) = [0; 2] (cfl=1)
1/2 = 0 + 1/2
1/2 = 0.5

contfrac(2/5) = [0; 2, 2] (cfl=2)
2/5 = 0 + 1/(2 + 1/2)
2/5 = 0.4

contfrac(3/8) = [0; 2, 1, 2] (cfl=3)
3/8 = 0 + 1/(2 + 1/(1 + 1/2))
3/8 = 0.375

contfrac(5/13) = [0; 2, 1, 1, 2] (cfl=4)
5/13 = 0 + 1/(2 + 1/(1 + 1/(1 + 1/2)))
5/13 = 0.384615384…

contfrac(8/21) = [0; 2, 1, 1, 1, 2] (cfl=5)
8/21 = 0 + 1/(2 + 1/(1 + 1/(1 + 1/(1 + 1/2))))
8/21 = 0.380952380…

contfrac(13/34) = [0; 2, 1, 1, 1, 1, 2] (cfl=6)
13/34 = 0 + 1/(2 + 1/(1 + 1/(1 + 1/(
1
+ 1/(1 + 1/2)))))
13/34 = 0.382352941..

contfrac(21/55) = [0; 2, 1, 1, 1, 1, 1, 2] (cfl=7)
21/55 = 0 + 1/(2 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/(1 + 1/2))))))
21/55 = 0.381818181…

contfrac(34/89) = [0; 2, 1, 1, 1, 1, 1, 1, 2] (cfl=8)
contfrac(55/144) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=9)
contfrac(89/233) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=10)
contfrac(144/377) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=11)
contfrac(233/610) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=12)
contfrac(377/987) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=13)
contfrac(610/1597) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=14)
contfrac(987/2584) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=15)
contfrac(1597/4181) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=16)
contfrac(2584/6765) = [0; 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] (cfl=17)
[…]


Now it’s the successive Fibonacci skip-one fractions, fib(i)/fib(i+2), that set records for the length of their palindromic continued fractions. But I think you’d have to be very good at maths not to be surprised by that result.

After that, I continued to be compelled by the Call of CFulhu and started to look at the CFs of Fibonacci skip-n fractions in general. That’s contfrac(fib(i)/fib(i+n)) for n = 1,2,3,… And I’ve found more interesting patterns, as I’ll describe in a follow-up post.

Message from Mater

As any recreational mathematician kno, the Ulam spiral shows the prime numbers on a spiral grid of integers. Here’s a Ulam spiral with 1 represented in blue and 2, 3, 5, 7… as white blocks spiralling anti-clockwise from the right of 1:

The Ulam spiral of prime numbers


Ulam spiral at higher resolution


I like the Ulam spiral and whenever I’m looking at new number sequences I like to Ulamize it, that is, display it on a spiral grid of integers. Sometimes the result looks good, sometimes it doesn’t. But I’ve always wondered something beforehand: will this be the spiral where I see a message appear? That is, will I see a message from Mater Mathematica, Mother Maths, the omniregnant goddess of mathematics? Is there an image or text embedded in some obscure number sequence, revealed when the sequence is Ulamized and proving that there’s divine intelligence and design behind the universe? Maybe the image of a pantocratic cat will appear. Or a text in Latin or Sanskrit or some other suitably century-sanctified language.

That’s what I wonder. I don’t wonder it seriously, of course, but I do wonder it. But until 22nd March 2025 I’d never seen any Ulam-ish spiral that looked remotely like a message. But 22nd May is the day I Ulamed some continued fractions. And I saw something that did look a little like a message. Like text, that is. But I might need to explain continued fractions first. What are they? They’re a fascinating and beautiful way of representing both rational and irrational numbers. The continued fractions for rational numbers look like this in expanded and compact format:

5/3 = 1 + 1/(1 + ½) = 1 + ⅔
5/3 = [1; 1, 2]

19/7 = 2 + 1/(1 + 1/(2 + ½)) = 2 + 4/7
19/7 = [2; 1, 2, 2]

2/3 = 0 + 1/(1 + 1/2)
2/3 = [0; 1, 2] (compare 5/3 above)

3/5 = 0 + 1/(1 + 1/(1 + 1/2))
3/5 = [0; 1, 1, 2]

5/7 = 0 + 1/(1 + 1/(2 + 1/2))
5/7 = [0; 1, 2, 2] (compare 19/7 above)

13/17 = 0 + 1/(1 + 1/(3 + 1/4))
13/17 = [0; 1, 3, 4]

30/67 = 0 + 1/(2 + 1/(4 + 1/(3 + ½)))
30/67 = [0; 2, 4, 3, 2]

The continued fractions of irrational numbers are different. Most importantly, they never end. For example, here are the infinite continued fractions for φ, √2 and π in expanded and compact format:

φ = 1 + (1/(1 + 1/(1 + 1/(1 + …)))φ = [1; 1]

√2 = 1 + (1/(2 + 1/(2 + 1/(2 + …)))
√2 = [1; 2]

π = 3 + 1/(7 + 1/(15 + 1/(1 + 1/(292 + 1/(1 + 1/(1 + 1/(1 + 1/(2 + 1/(1 + 1/(3 +…))))))))))
π = [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3…]

As you can see, the continued fraction of π doesn’t fall into a predictable pattern like those for φ and √2. But I’ve already gone into continued fractions further than I need for this post, so let’s return to the continued fractions of rationals. I set up an Ulam spiral to show patterns based on the continued fractions for 1/1, ½, ⅓, ⅔, 1/4, 2/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 2/6, 3/6… (where the fractions are assigned to 1,2,3… and 2/4 = ½, 2/6 = ⅓ etc). For example, if the continued fraction contains a number higher than 5, you get this spiral:

Spiral for continued fractions containing at least number > 5


With tests for higher and higher numbers in the continued fractions, the spirals start to thin and apparent symbols start to appear in the arms of the spirals:

Spiral for contfrac > 10


Spiral for contfrac > 15


Spiral for contfrac > 20


Spiral for contfrac > 25


Spiral for contfrac > 30


Spiral for contfrac > 35


Spiral for contfrac > 40


Spirals for contfrac > 5..40 (animated at EZgif)


Here are some more of these spirals at increasing magnification:

Spiral for contfrac > 23 (#1)


Spiral for contfrac > 23 (#2)


Spiral for contfrac > 23 (#3)


Spiral for contfrac > 13


Spiral for contfrac > 15 (off-center)


Spiral for contfrac > 23 (off-center)


And here are some of the symbols picked out in blue:

Spiral for contfrac > 15 (blue symbols)


Spiral for contfrac > 23 (blue symbols)


But they’re not really symbols, of course. They’re quasi-symbols, artefacts of the Ulamization of a simple test on continued fractions. Still, they’re the closest I’ve got so far to a message from Mater Mathematica.

Harcissism (Caveat Lector!)

Pre-previously on Overlord-of-the-Über-Feral, I looked at patterns like these, where sums of consecutive integers, sum(n1..n2), yield a number, n1n2, whose digits reproduce those of n1 and n2:


15 = sum(1..5)
27 = sum(2..7)
429 = sum(4..29)
1353 = sum(13..53)
1863 = sum(18..63)


Numbers like those can be called narcissistic, because in a sense they gaze back at themselves. Now I’ve looked at sums of consecutive reciprocals and found comparable narcissistic patterns:


0.45 = sum(1/4..1/5)
1.683... = sum(1/16..1/83)
0.361517... = sum(1/361..1/517)
3.61316... = sum(1/36..1/1316)
4.22847... = sum(1/42..1/2847)
3.177592... = sum(1/317..1/7592)
8.30288... = sum(1/8..1/30288)


Because the sum of consecutive reciprocals, 1/1 + 1/2 + 1/3 + 1/4…, is called the harmonic series, I’ve decided to call these numbers harcissistic = harmonic + narcissistic.


Post-Performative Post-Scriptum

Why did I put “Caveat Lector” (meaning “let the reader beware”) in the title of this post? Because it’s likely that some (or even most) fluent readers of English will misread the preceding word, “Harcissism”, as “Narcissism”.


Previously Pre-Posted (Please Peruse)

Fair Pairs — looking at patterns like 1353 = sum(13..53)

Fract-L Geometry

Suppose you set up an L, i.e. a vertical and horizontal line, representing the x,y coordinates between 0 and 1. Next, find the fractional pairs x = 1/2, 1/3, 2/3, 1/4, 2/4…, y = 1/2, 1/3, 2/3, 1/4, 2/4… and mark the point (x,y). That is, find the point, say, 1/5 of the way along the x-line, then the points 1/5, 2/5, 3/5 and 4/5 along the y-line, marking the points (1/5, 1/5), (1/5, 2/5), (1/5, 3/5), (1/5, 4/5). Then find (2/5, 1/5), (2/5, 2/5), (2/5, 3/5), (2/5, 4/5) and so on. Some interesting patterns appear in what I call a Frac-L (pronounced “frackle”) or Fract-L:

Frac-L for 1/2 to 21/22


Frac-L for 1/2 to 48/49


Frac-L for 1/2 to 75/76


Frac-L for 1/2 to 102/103


Frac-L for 1/2 to 102/103 (animated)


If the (x,y) point is first red, then becomes different colors as it is repeatedly found, you get these patterns:

Frac-L for 1/2 to 48/49 (color)


Frac-L for 1/2 to 75/79 (color)


Frac-L for 1/2 to 102/103 (color) (animated)


Now try polygonal numbers. The triangular numbers are 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78…, so you’re finding the fractional pairs, say, (1/21, 1/21), (1/21, 3/21, (1/21, 6/21), (1/21, 10/21), (1/21, 15/21), then (3/21, 1/21), (3/21, 3/21, (3/21, 6/21), (3/21, 10/21), (3/21, 15/21), and so on:

Frac-L for triangular fractions


The frac-L for square numbers (1, 4, 9, 16, 25, 36, 49, 64, 81, 100…) is almost identical:

Frac-L for square fractions, e.g. (1/16, 1/16), (1/16, 4/16), (1/16, 9/16)…


So is the frac-L for pentagonal numbers (1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176, 210, 247, 287, 330…):

Frac-L for pentagonal fractions, e.g. (1/35, 5/35), (1/35, 12/35), (1/35,22/35)…


Here are frac-Ls for tetrahedral and square-pyramidal numbers:

Frac-L for tetrahedral fractions


Frac-L for square pyramidal fractions


But what about prime numbers (skipping 2)? Here the fractional pairs are, say, (1/17, 1/17), (1/17, 3/17), (1/17, 5/17), (1/17, 7/17), (1/17, 11/17), (1/17, 13/17), then (3/17, 1/17), (3/17, 3/17), (3/17, 5/17), (3/17, 7/17), (3/17, 11/17), (3/17, 13/17), and so on:

Frac-L for 1/3 to 73/79 (prime fractions)


Frac-L for 1/3 to 223/227


Frac-L for 1/3 to 307/331


Frac-L for 1/3 to 307/331 (animated)


Frac-L for 1/3 to 73/79 (color) (prime fractions)


Frac-L for 1/3 to 223/227 (color)


Frac-L for 1/3 to 307/331 (color)


Frac-L for 1/3 to 307/331 (color) (animated)


And finally (for now), a frac-L for Fibonnaci numbers, where the fractional pairs are, say, (1/13, /13), (1/13, 2/13), (1/13, 3/13), (1/13, 5/13), (1/13, 8/13), then (2/13, /13), (2/13, 2/13), (2/13, 3/13), (2/13, 5/13), (2/13, 8/13), and so on:

Frac-L for Fibonacci fractions to 14930352/2178309 = fibonacci(36)/fibonacci(37)


hail(Satan)!

It’s a very simple function that raises a very difficult question. An unanswered question, in fact. Take any whole number. If it’s odd, multiply it by 3 and add 1. If it’s even, divide it by 2. Repeat until you reach 1. That’s the hailstone function, because the numbers rise and fall like hailstones being formed in a cloud. Here are some examples:

5 → 16 → 8 → 4 → 2 → 1 (steps=5)


3 → 10 → 5 → 16 → 8 → 4 → 2 → 1 (st=7)


7 → 22 → 11 → 34 → 17 → 52 → 26 → 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 (st=16)

Graph for hail(7) = 16 (mx=52)


25 → 76 → 38 → 19 → 58 → 29 → 88 → 44 → 22 → 11 → 34 → 17 → 52 → 26 → 13 → 40 →
20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 (st=23)

Graph for hail(25) = 23 (mx=88)


But is this function truly a hailstone function? That is, does every number fall finally to earth and reach 1? So far, for every number tested, the answer has been yes. But do all numbers reach 1? The Collatz conjecture says they do. But no-one can prove it. Or disprove it. All it would take is one number failing to fall to earth. Mathematicians don’t think there is one, but numbers can take a surprising length of time to get to the ground. Here’s 27:

27 → 82 → 41 → 124 → 62 → 31 → 94 → 47 → 142 → 71 → 214 → 107 → 322 → 161 → 484 → 242 → 121 → 364 → 182 → 91 → 274 → 137 → 412 → 206 → 103 → 310 → 155 → 466 → 233 → 700 → 350 → 175 → 526 → 263 → 790 → 395 → 1186 → 593 → 1780 → 890 → 445 → 1336 → 668 → 334 → 167 → 502 → 251 → 754 → 377 → 1132 → 566 → 283 → 850 → 425 → 1276 → 638 → 319 → 958 → 479 → 1438 → 719 → 2158 → 1079 → 3238 → 1619 → 4858 → 2429 → 7288 → 3644 → 1822 → 911 → 2734 → 1367 → 4102 → 2051 → 6154 → 3077 → 9232 → 4616 → 2308 → 1154 → 577 → 1732 → 866 → 433 → 1300 → 650 → 325 → 976 → 488 → 244 → 122 → 61 → 184 → 92 → 46 → 23 → 70 → 35 → 106 → 53 → 160 → 80 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 (st=111)

Graph for hail(27) = 111 (mx=9232)


27 takes 111 steps to reach 1. And the 111 made me think of another question. If the function hail(n) returns the number of steps required for n to reach 1, then hail(27) = 111. But what about hail(n) = 666? That is, what is the first number that requires 666 steps to reach 1? I say “first number”, because one very big number is guaranteed to take 666 steps:

666 = hail(306,180,206,916,083,902,309,240,650,087,602,475,282,639,486,413,866,622,
577,088,471,913,520,022,894,784,390,350,900,738,050,555,138,105,234,536,857,820,245,
071,373,614,031,482,942,161,565,170,086,143,298,589,738,273,508,330,367,307,539,078,
392,896,587,187,265,470,464)

Put another way, 666 = hail(2^666), because for any power of 2, hail(2^p) = p. But is there a smaller number, which I’ll call satan, for which hail(satan) = 666? Here’s a tantalizing taster of the task:

hail(27) = 111 (mx=9232)
hail(30262) = 222 (mx=2484916)
hail(164521) = 333 (mx=21933016)
hail(886953) = 444 (mx=52483285312)
hail(5143151) = 555 (mx=125218704148)
hail(satan) = 666 (mx=?)


But what is satan? Before I answer, here are some more graphs for interesting hail(n):

hail(231) = 127 (mx=9232)


hail(327) = 143 (mx=9232)


hail(703) = 170 (mx=250504)


hail(871) = 178 (mx=190996)


hail(2223) = 182 (mx=250504)


hail(3711) = 237 (mx=481624)


hail(35655) = 323 (mx=41163712)


hail(142587) = 374 (mx=593279152)


Now I’ll answer the question. If satan = 26597116, then hail(satan) = 666:

hail(26597116) = 666 (mx=15208728208)


Therefore:

hail(satan)! =
1,010,632,056,840,781,493,390,822,708,129,876,451,757,582,398,324,145,411,
340,420,807,357,413,802,103,697,022,989,202,806,801,491,012,040,989,802,
203,557,527,039,339,704,057,130,729,302,834,542,423,840,165,856,428,740,
661,530,297,972,410,682,828,699,397,176,884,342,513,509,493,787,480,774,
903,493,389,255,262,878,341,761,883,261,899,426,484,944,657,161,693,131,
380,311,117,619,573,051,526,423,320,389,641,805,410,816,067,607,893,067,
483,259,816,815,364,609,828,668,662,748,110,385,603,657,973,284,604,842,
078,094,141,556,427,708,745,345,100,598,829,488,472,505,949,071,967,727,
270,911,965,060,885,209,294,340,665,506,480,226,426,083,357,901,503,097,
781,140,832,497,013,738,079,112,777,615,719,116,203,317,542,199,999,489,
227,144,752,667,085,796,752,482,688,850,461,263,732,284,539,176,142,365,
823,973,696,764,537,603,278,769,322,286,708,855,475,069,835,681,643,710,
846,140,569,769,330,065,775,414,413,083,501,043,659,572,299,454,446,517,
242,824,002,140,555,140,464,296,291,001,901,438,414,675,730,552,964,914,
569,269,734,038,500,764,140,551,143,642,836,128,613,304,734,147,348,086,
095,123,859,660,926,788,460,671,181,469,216,252,213,374,650,499,557,831,
741,950,594,827,147,225,699,896,414,088,694,251,261,045,196,672,567,495,
532,228,826,719,381,606,116,974,003,112,642,111,561,332,573,503,212,960,
729,711,781,993,903,877,416,394,381,718,464,765,527,575,014,252,129,040,
283,236,963,922,624,344,456,975,024,058,167,368,431,809,068,544,577,258,
472,983,979,437,818,072,648,213,608,650,098,749,369,761,056,961,203,791,
265,363,665,664,696,802,245,199,962,040,041,544,438,210,327,210,476,982,
203,348,458,596,093,079,296,569,561,267,409,473,914,124,132,102,055,811,
493,736,199,668,788,534,872,321,705,360,511,305,248,710,796,441,479,213,
354,542,583,576,076,596,250,213,454,667,968,837,996,023,273,163,069,094,
700,429,467,106,663,925,419,581,193,136,339,860,545,658,673,623,955,231,
932,399,404,809,404,108,767,232,000,000,000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,000 = 666!


Here’s a question I haven’t answered: if satanic numbers are those n satisfying hail(n) = 666, how many satanic numbers are there? We’ve already seen two of them: 666 = hail(2^666) = hail(26597116). But how many more are there? Not infinitely many, because for n > 2^666, hail(n) > 666. In fact, after satan = 26597116, the next three satanic numbers arrive very quickly:

hail(satan+0) = 666 = hail(26597116)
hail(satan+1) = 666 = hail(26597117)
hail(satan+2) = 666 = hail(26597118)
hail(satan+3) = 666 = hail(26597119)

hail(satan-1) = 180 = hail(26597115)
hail(satan+4) = 180 = hail(26597120)


So there are four consecutive satanic numbers. But it isn’t unusual for a run of consecutive numbers to have the same hail(). Here’s a graph of the values of hail(n) for n = 1,2,3… (running left-to-right, down-up, with 1,2,3… in the lower lefthand corner). When n is divisible by 10, hail(n) is represented in red; when n is odd and divisible by 5, hail(n) is green. Note how many runs of identical hail(n) there are:

Graph for hail(n)


Here are successive records for runs of identical hail(n):

hail(12..13) = 9 (run=2)
hail(28..30) = 18 (run=3)
hail(98..102) = 25 (r=5)
hail(386..391) = 120 (r=6)
hail(943..949) = 36 (r=7)
hail(1494..1501) = 47 (r=8)
hail(1680..1688) = 42 (r=9)
hail(2987..3000) = 48 (r=14)
hail(7083..7099) = 57 (r=17)
hail(57346..57370) = 78 (r=25)
hail(252548..252574) = 181 (r=27)
hail(331778..331806) = 91 (r=29)
hail(524289..524318) = 102 (r=30)
hail(596310..596349) = 97 (r=40)


Finally, here’s Poland’s finest putting the function of 26597116 to music:

“Hail Satan!” by Dopelord


Elsewhere Other-Accessible…

Dopelord at Bandcamp

Fabulous Furry Fibonacci Fractal

At least, I think it’s a fractal. I came across it when I was counting the ways in which the integers can be the sum of distinct Fibonacci numbers. Here for reference is the Fibonacci sequence, the beautiful and endlessly fertile sequence that’s seeded with “1, 1” and continued by summing the two previous numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040…

I noticed some interesting patterns in the distinct-fib-num-sum count for the integers:

1 = 1 (count=1)
2 = 2 (count=1)
3 = 1+2 = 3 (count=2)
4 = 1+3 (c=1)
5 = 2+3 = 5 (c=2)
6 = 1+2+3 = 1+5 (c=2)
7 = 2+5 (c=1)
8 = 1+2+5 = 3+5 = 8 (c=3)
9 = 1+3+5 = 1+8 (c=2)
10 = 2+3+5 = 2+8 (c=2)
11 = 1+2+3+5 = 1+2+8 = 3+8 (c=3)
12 = 1+3+8 (c=1)
13 = 2+3+8 = 5+8 = 13 (c=3)
14 = 1+2+3+8 = 1+5+8 = 1+13 (c=3)
15 = 2+5+8 = 2+13 (c=2)
16 = 1+2+5+8 = 3+5+8 = 1+2+13 = 3+13 (c=4)
17 = 1+3+5+8 = 1+3+13 (c=2)
18 = 2+3+5+8 = 2+3+13 = 5+13 (c=3)
19 = 1+2+3+5+8 = 1+2+3+13 = 1+5+13 (c=3)
20 = 2+5+13 (c=1)
21 = 1+2+5+13 = 3+5+13 = 8+13 = 21 (c=4)
22 = 1+3+5+13 = 1+8+13 = 1+21 (c=3)
23 = 2+3+5+13 = 2+8+13 = 2+21 (c=3)
24 = 1+2+3+5+13 = 1+2+8+13 = 3+8+13 = 1+2+21 = 3+21 (c=5)
25 = 1+3+8+13 = 1+3+21 (c=2)
26 = 2+3+8+13 = 5+8+13 = 2+3+21 = 5+21 (c=4)
27 = 1+2+3+8+13 = 1+5+8+13 = 1+2+3+21 = 1+5+21 (c=4)
28 = 2+5+8+13 = 2+5+21 (c=2)
29 = 1+2+5+8+13 = 3+5+8+13 = 1+2+5+21 = 3+5+21 = 8+21 (c=5)
30 = 1+3+5+8+13 = 1+3+5+21 = 1+8+21 (c=3)
31 = 2+3+5+8+13 = 2+3+5+21 = 2+8+21 (c=3)
32 = 1+2+3+5+8+13 = 1+2+3+5+21 = 1+2+8+21 = 3+8+21 (c=4)
33 = 1+3+8+21 (c=1)
34 = 2+3+8+21 = 5+8+21 = 13+21 = 34 (c=4)
35 = 1+2+3+8+21 = 1+5+8+21 = 1+13+21 = 1+34 (c=4)
36 = 2+5+8+21 = 2+13+21 = 2+34 (c=3)
37 = 1+2+5+8+21 = 3+5+8+21 = 1+2+13+21 = 3+13+21 = 1+2+34 = 3+34
(c=6)
38 = 1+3+5+8+21 = 1+3+13+21 = 1+3+34 (c=3)
39 = 2+3+5+8+21 = 2+3+13+21 = 5+13+21 = 2+3+34 = 5+34 (c=5)
40 = 1+2+3+5+8+21 = 1+2+3+13+21 = 1+5+13+21 = 1+2+3+34 = 1+5+34
(c=5)
41 = 2+5+13+21 = 2+5+34 (c=2)
42 = 1+2+5+13+21 = 3+5+13+21 = 8+13+21 = 1+2+5+34 = 3+5+34 = 8+3
4 (c=6)
43 = 1+3+5+13+21 = 1+8+13+21 = 1+3+5+34 = 1+8+34 (c=4)
44 = 2+3+5+13+21 = 2+8+13+21 = 2+3+5+34 = 2+8+34 (c=4)
45 = 1+2+3+5+13+21 = 1+2+8+13+21 = 3+8+13+21 = 1+2+3+5+34 = 1+2+
8+34 = 3+8+34 (c=6)
46 = 1+3+8+13+21 = 1+3+8+34 (c=2)
47 = 2+3+8+13+21 = 5+8+13+21 = 2+3+8+34 = 5+8+34 = 13+34 (c=5)
48 = 1+2+3+8+13+21 = 1+5+8+13+21 = 1+2+3+8+34 = 1+5+8+34 = 1+13+
34 (c=5)
49 = 2+5+8+13+21 = 2+5+8+34 = 2+13+34 (c=3)
50 = 1+2+5+8+13+21 = 3+5+8+13+21 = 1+2+5+8+34 = 3+5+8+34 = 1+2+1
3+34 = 3+13+34 (c=6)
51 = 1+3+5+8+13+21 = 1+3+5+8+34 = 1+3+13+34 (c=3)
52 = 2+3+5+8+13+21 = 2+3+5+8+34 = 2+3+13+34 = 5+13+34 (c=4)
53 = 1+2+3+5+8+13+21 = 1+2+3+5+8+34 = 1+2+3+13+34 = 1+5+13+34 (c=4)
54 = 2+5+13+34 (c=1)
55 = 1+2+5+13+34 = 3+5+13+34 = 8+13+34 = 21+34 = 55 (c=5)
56 = 1+3+5+13+34 = 1+8+13+34 = 1+21+34 = 1+55 (c=4)

The patterns are easier to see when the counts are set out like this:

1, 1, 2, 1, 2, 2, 1, 3, 2, 2, 3, 1, 3, 3, 2, 4, 2, 3, 3, 1, 4, 3, 3, 5, 2, 4, 4, 2, 5, 3, 3, 4, 1, 4, 4, 3, 6, 3, 5, 5, 2, 6, 4, 4, 6, 2, 5, 5, 3, 6, 3, 4, 4, 1, 5, 4, 4, 7, 3, 6, 6, 3, 8, 5, 5, 7, 2, 6, 6, 4, 8, 4, 6, 6, 2, 7, 5, 5, 8, 3, 6, 6, 3, 7, 4, 4, 5, 1, 5, 5, 4, 8, 4, 7, 7, 3, 9, 6, 6, 9, 3, 8, 8, 5, 10, 5, 7, 7, 2, 8, 6, 6, 10, 4, 8, 8, 4, 10, 6, 6, 8, 2, 7, 7, 5, 10, 5, 8, 8, 3, 9, 6, 6, 9, 3, 7, 7, 4, 8, 4, 5, 5, 1, 6, 5, 5, 9, 4, 8, 8… 1… — See A000119, Number of representations of n as a sum of distinct Fibonacci numbers, at the Online Encyclopedia of Integer Sequences (OEIS)

The numbers between each pair of 1s are symmetrical:

1, 2, 1,
1, 2, 2, 1,
1, 3, 2, 2, 3, 1,
1, 3, 3, 2, 4, 2, 3, 3, 1
1, 4, 3, 3, 5, 2, 4, 4, 2, 5, 3, 3, 4, 1

And when fibsumcount(n) = 1, then n = fib(i)-1, i.e. n is one less than a Fibonacci number:

1 = 1 (c=1)
2 = 2 (c=1)
4 = 1+3 (c=1)
7 = 2+5 (c=1)
12 = 1+3+8 (c=1)
20 = 2+5+13 (c=1)
33 = 1+3+8+21 (c=1)
54 = 2+5+13+34 (c=1)
88 = 1+3+8+21+55 (c=1)
143 = 2+5+13+34+89 (c=1)
232 = 1+3+8+21+55+144 (c=1)
376 = 2+5+13+34+89+233 (c=1)
609 = 1+3+8+21+55+144+377 (c=1)
986 = 2+5+13+34+89+233+610 (c=1)
1596 = 1+3+8+21+55+144+377+987 (c=1)
2583 = 2+5+13+34+89+233+610+1597 (c=1)
4180 = 1+3+8+21+55+144+377+987+2584 (c=1)
6764 = 2+5+13+34+89+233+610+1597+4181 (c=1)
10945 = 1+3+8+21+55+144+377+987+2584+6765 (c=1)
17710 = 2+5+13+34+89+233+610+1597+4181+10946 (c=1)
[…]

I also noticed a pattern relating to the maximum count reached in the numbers between the 1s. Suppose the function max(fib(i)-1..fib(i+1)-1) returns the highest count of ways to represent the numbers from fib(i)-1 to fib(i+1)-1. Notice how max() increases:

max(2..4) = 2
max(4..7) = 2
max(7..12) = 3
max(12..20) = 4
max(20..33) = 5
max(33..54) = 6
max(54..88) = 8
max(88..143) = 10
max(143..232) = 13
max(232..376) = 16
max(376..609) = 21
max(609..986) = 26
max(986..1596) = 34
max(1596..2583) = 42
max(2583..4180) = 55
max(4180..6764) = 68
[…]

The pattern is described like this at the Online Encyclopedia of Integer Sequences:

a(n) = 1 if and only if n+1 is a Fibonacci number. The length of such a quasi-period (from Fib(i)-1 to Fib(i+1)-1, inclusive) is a Fibonacci number + 1. The maximum value of a(n) within each subsequent quasi-period increases by a Fibonacci number. For example, from n = 143 to n = 232, the maximum is 13. From 232 to 376, the maximum is 16, an increase of 3. From 376 to 609, 21, an increase of 5. From 609 to 986, 26, increasing by 5 again. Each two subsequent maxima seem to increase by the same increment, the next Fibonacci number. – Kerry Mitchell, Nov 14 2009

The maxima of the quasi-periods are in A096748. – Max Barrentine, Sep 13 2015 — See commentary for A000119 at OEIS

Here is A096748:

1, 2, 2, 2, 3, 4, 5, 6, 8, 10, 13, 16, 21, 26, 34, 42, 55, 68, 89, 110, 144, 178, 233, 288, 377, 466, 610, 754, 987, 1220, 1597, 1974, 2584, 3194, 4181, 5168, 6765, 8362, 10946, 13530, 17711, 21892, 28657, 35422, 46368, 57314, 75025, 92736, 121393, 150050 — A096748, Expansion of (1+x)^2/(1-x^2-x^4), at OEIS

These maxima are the succesive highest points in a graph of A000119, Number of representations of n as a sum of distinct Fibonacci numbers:

Graph of count of ways in which 1,2,3… can be sum of distinct Fibonacci numbers


The graph looks like a furry caterpillar or similar and the symmetry of counts between the 1s is more obvious there:

fibsumcounts for 33..54


fibsumcounts for 54..88


fibsumcounts for 88..143


fibsumcounts for 143..232


fibsumcounts for 232..376


fibsumcounts for 376..609


And the fractal nature of the counts is more obvious when the graph is rotated by 90° and then mirrored:

Rotated and mirrored graph of count of ways in which 1,2,3… can be sum of distinct Fibonacci numbers

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