I Like Gryke

Sometimes I find fractals. And sometimes fractals find me. Here’s a fractal that found me:

Limestone fractal #1


I call it a limestone fractal or pavement fractal or gryke fractal, because it reminds me of the fissured patterns you see in the limestone pavements of the Yorkshire Dales:

Fissured limestone pavement, Yorkshire Dales (Wikipedia)


The limestone blocks are called clints and the larger fissures between them are called grykes, with kamenitza and karren (from Slavic and German, respectively) for smaller pits and grooves:

Limestone linguistics (Dales Rocks)


Here’s the me-finding fractal again, in a slightly different version:

Limestone fractal #2


How did it find me? Well, I wasn’t looking for fractals, but looking at fractions. Farey fractions and Calkin-Wilf fractions, to be precise. They can both be represented as bifurcating trees, like this:

Calkin-Wilf tree (Wikipedia)


Both trees produce all the irreducible rational fractions — but in a different order. That’s why they create a fractal (rather than a 45° line). By following the same path in both bifurcating trees, I generated parallel sequences of Farey and Calkin-Wilf fractions, then used the Farey fractions to represent x in a 1×1 square and the Calkin-Wilf fractions to represent y (where the Calkin-Wilfs, a/b, were greater than 1, I simply a/b → b/a). When you do that (or use Stern-Brocot fractions instead of the Farey fractions), you get the limestone fractal.

I think it looks better in the second version (which is the one that found me, in fact). For LF #2, I was using standard binary numbers to generate the parallel sequences, so the leftmost digit was always 1 and final step of the tree-search was always in the same direction. Here’s LF #2 as black-on-white rather than white-on-black:

Limestone fractal #2 (black-on-white)


And here is the formation of LF #1 as an animated gif:

Growth of limestone fractal (animated at ezGIF)


And if that’s a me-finding fractal, what about me-found fractals? Here’s one:

The Hourglass Fractal (animated gif optimized at ezGIF)

Hourglass fractal


I can say “I found that fractal” because I was looking for fractals when it appeared on the screen. And re-appeared (and re-re-appeared), because I’ve found it using different methods.


Elsewhere Other-Accessible

Hour Power — more on the hourglass fractal

The Bellissima Curve

The bell curve is a shape that appears when you make a graph by counting all possible sums of a range of integers like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The smallest sum you can get is 1; the largest is 55 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10. But there’s only one sum of 1 and only one sum of 55. Other sums are more common:

• 10 = 1 + 2 + 3 + 4
• 10 = 1 + 2 + 7
• 10 = 1 + 3 + 6
• 10 = 1 + 4 + 5
• 10 = 2 + 3 + 5
• 10 = 2 + 8
• 10 = 3 + 7
• 10 = 4 + 6
• 10 = 10

So there are nine sums of 10. If you graph count-sums with a bigger set of consecutive integers from 1, 2, 3…, you get this shape:

Bell curve from sum-counts with 1, 2, 3, 4, 5, 6, 7, 8, 9, 10…
(open in separate window for full-sized image)


It’s a bell curve. Et c’est une belle curve, a “beautiful curve” in French. But I’ve found what I call bellissime curve — Italian for “most beautiful curves” — by sampling different sets of integers. With the set (1, 3, 5, 7, 9, 11, 13, 15, 17, 19…), you get what you could call a slightly wrinkled bell curve:

Wrinkled bell-curve from sum-counts with 1, 3, 5, 7, 9, 11, 13, 15, 17, 19…
(open in separate window for full-sized image)


After that, as you leave bigger gaps in the sampled sets, the curves start to overlap and add extra beauty:

Overlapping bell curves from sum-counts with 1, 4, 7, 10, 13, 16, 19, 22, 25, 28…


Bellissima curves from sum-counts with 1, 5, 9, 13, 17, 21, 25, 29, 33, 37…


Bellissima curves from sum-counts with 1, 6, 11, 16, 21, 26, 31, 36, 41, 46…


Bellissima curves from sum-counts with 1, 7, 13, 19, 25, 31, 37, 43, 49, 55…


With the set (3, 6, 9, 15, 18, 21…), the bell is back:

Bell curve from sum-counts with 3, 6, 9, 15, 18, 21…


But with (4, 7, 10, 13, 6, 19…), separated by the same distance, you get this:

Bell curve from sum-counts with 4, 7, 10, 13, 6, 19…


When you sample the Fibonacci numbers, (1, 2, 3, 5, 8…), you get this graph:

Caterpillar curve from sum-counts of Fibonacci numbers 1, 2, 3, 5, 8, 13, 21, 34, 55, 89…


When you sample a restricted set of Fibonaccis, (1, 3, 8, 21, 55…), you get this, where each vertical line represents a count of one:

Golden gaps from sum-counts of restricted Fibonacci numbers 1, 3, 8, 21, 55, 144…


That restricted Fibonacci graph is strangely attractive, because it has golden gaps (verb sap!).

Friday is Φiday

The 11th, 12th and 23rd day of a month can be called a φ-day (pronounced fy-day). Why so? Because those numbers are consecutive entries in the famous Fibonacci sequence, which offers better and better approximations to a mathematical constant called φ = (√5 + 1) / 2 = 1.6180339887498948…:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, …

Each number after the second is the sum of the preceding two (so 11, 12, 23… could be the start of a similar sequence). When you divide fib(i) by fib(i-1), you get these approximations to φ:

2 = 2/1
1.5 = 3/2
1.6 = 5/3
1.6 = 8/5
1.625 = 13/8
1.6153846… = 21/13
1.619047619… = 34/21
1.6176470588235294117647… = 55/34
1.618… = 89/55
1.617977528… = 144/89
1.61805… = 233/144
1.618025751… = 377/233
1.618037135… = 610/377
1.618032786… = 987/610
1.618034447… = 1597/987
1.618033813… = 2584/1597
1.618034055… = 4181/2584
1.618033963… = 6765/4181
1.618033998… = 10946/6765
1.618033985… = 17711/10946

Today is the 23rd and not just a φ-day but a Friday (or φriday). So here’s one of the interesting results I’ve recently found while playing with the Fibonacci sequence. As any recreational mathematician kno, you can also find the Fibonacci sequence — and φ — with this little algorithm:

f = 0
LOOP
f = 1 / (f + 1)
print(f)
goto LOOP

The algorithm returns these values:

1, 1/2, 2/3, 3/5, 5/8, 8/13, 13/21, 21/34, 34/55, 55/89, 89/144, 144/233, 233/377, 377/610, 610/987, 987/1597, 1597/2584, 2584/4181, 4181/6765, 6765/10946, 10946/17711, …

I was playing with that algorithm and got an unexpected result with a simple adaptation of it:

f = 0
LOOP
f = 1 / (3 – f)
print(f)
goto LOOP

The values of f generated by this adapted algorithm are:

1/3, 3/8, 8/21, 21/55, 55/144, 144/377, 377/987, 987/2584, 2584/6765, 6765/17711, 17711/46368, 46368/121393, 121393/317811, 317811/832040, 832040/2178309, 2178309/5702887, 5702887/14930352, 14930352/39088169, 39088169/102334155, 102334155/267914296, …

The numerator and denominator in each fraction are next-but-one Fibonacci numbers, beautifully generated at each step:

3 – 0 = 3 → 1/3
3 – 1/3 = (3*3)/3 – 1/3 = 9/3 – 1/3 = (9-1) / 3 = 8 / 3 → 1/(8/3) = 3/8
3 – 3/8 = (3*8)/3 – 3/8 = 24/8 – 3/8 = (24-3) / 8 = 21/8 → 1/(21/8) = 8/21
3 – 8/21 = (3*21)/21 – 8/21 = 63/21 – 8/21 = (63-8)/21 = 55/21 → 1/(55/21) = 21/55
3 – 21/55 = (3*55)/55 – 21/55 = 165/55 – 21/55 = (165-21)/55 = 144/55 → 1/(144/55) = 55/144
3 – 55/144 = (3*144)/144 – 55/144 = (432-55)/144 = 377/144 → 1/(377/144) = 144/377
3 – 144/377 = (3*377)/377 – 144/377 = (1131-144)/377 = 987/377 → 1/(987/377) = 377/987
[…]

If you reverse numerator and denominator, the limit of the fraction is φ^2 = 2.6180339887498948… = φ+1:

3 = 3/1
2.6 = 8/3
2.625 = 21/8
2.6190476190476190476190476… = 55/21
2.6181818181818181818181818… = 144/55
2.6180555555555555555555555… = 377/144
2.6180371352785145888594164… = 987/377
2.6180344478216818642350557… = 2584/987
2.6180340557275541795665634… = 6765/2584
2.6180339985218033998521803… = 17711/6765
2.6180339901755970865563773… = 46368/17711
2.6180339889579020013802622… = 121393/46368
2.6180339887802426828565073… = 317811/121393
2.6180339887543225376088304… = 832040/317811
2.6180339887505408393827219… = 2178309/832040
2.6180339887499890970472967… = 5702887/2178309
2.6180339887499085989254214… = 14930352/5702887
2.6180339887498968544077192… = 39088169/14930352
2.6180339887498951409056791… = 102334155/39088169
2.6180339887498948909091006… = 267914296/102334155

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.

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)

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

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