Pi in the Bi

Binary is beautiful — both simple and subtle. What could be simpler than using only two digits to count with?


0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, 10010, 10011, 10100, 10101, 10110, 10111, 11000, 11001, 11010, 11011, 11100, 11101, 11110, 11111, 100000, 100001, 100010, 100011, 100100, 100101, 100110, 100111, 101000, 101001, 101010, 101011, 101100, 101101, 101110, 101111, 110000, 110001, 110010, 110011, 110100, 110101, 110110, 110111, 111000, 111001, 111010, 111011, 111100, 111101, 111110, 111111, 1000000...

But the simple patterns in the two digits of binary involve two of the most important numbers in mathematics: π and e (aka Euler’s number):


π = 3.141592653589793238462643383...
e = 2.718281828459045235360287471...

It’s easy to write π and e in binary:


π = 11.00100 10000 11111 10110 10101 00010...
e = 10.10110 11111 10000 10101 00010 11000...

But how do π and e appear in the patterns of binary 1 and 0? Well, suppose you use the digits of binary to generate the sums of distinct integers. For example, here are the sums of distinct integers you can generate with three digits of binary, if you count the digits from right to left (so the rightmost digit is 1, the the next-to-rightmost digit is 2, the next-to-leftmost digit is 3, and the leftmost digit is 4):


0000 → 0*4 + 0*3 + 0*2 + 0*1 = 0
0001 → 0*4 + 0*3 + 0*2 + 1*1 = 1*1 = 1
0010 → 0*4 + 0*3 + 1*2 + 0*1 = 1*2 = 2
0011 → 0*4 + 0*3 + 1*2 + 1*1 = 1*2 + 1*1 = 3
0100 → 1*3 = 3
0101 → 1*3 + 1*1 = 4
0110 → 3 + 2 = 5
0111 → 3 + 2 + 1 = 6
1000 → 4
1001 → 4 + 1 = 5
1010 → 4 + 2 = 6
1011 → 4 + 2 + 1 = 7
1100 → 4 + 3 = 7
1101 → 4 + 3 + 1 = 8
1110 → 4 + 3 + 2 = 9
1111 → 4 + 3 + 2 + 1 = 10

There are 16 sums (16 = 2^4) generating 11 integers, 0 to 10. But some integers involve more than one sum:


3 = 2 + 1 ← 0011
3 = 3 ← 0100

4 = 3 + 1 ← 0101
4 = 4 ← 1000

5 = 3 + 2 ← 0110
5 = 4 + 1 ← 1001

6 = 3 + 2 + 1 ← 0111
6 = 4 + 2 ← 1010

7 = 4 + 2 + 1 ← 1011
7 = 4 + 3 ← 1100

Note the symmetry of the sums: the binary number 0011, yielding 3, is the mirror of 1100, yielding 7; the binary number 0100, yielding 3 again, is the mirror of 1011, yielding 7 again. In each pair of mirror-sums, the two numbers, 3 and 7, are related by the formula 10-3 = 7 and 10-7 = 3. This also applies to 4 and 6, where 10-4 = 6 and 10-6 = 4, and to 5, which is its own mirror (because 10-5 = 5). Now, try mapping the number of distinct sums for 0 to 10 as a graph:

Graph for distinct sums of the integers 0 to 4


The graph show how 0, 1 and 2 have one sum each, 3, 4, 5, 6 and 7 have two sums each, and 8, 9 and 10 have one sum each. Now look at the graph for sums derived from three digits of binary:

Graph for distinct sums of the integers 0 to 3


The single taller line of the seven lines represents the two sums of 3, because three digits of binary yield only one sum for 0, 1, 2, 4, 5 and 6:


000 → 0
001 → 1
010 → 2
011 → 2 + 1 = 3
100 → 3
101 → 3 + 1 = 4
110 → 3 + 2 = 5
111 → 3 + 2 + 1 = 6

Next, look at graphs for sums derived from one to sixteen binary digits and note how the symmetry of the lines begins to create a beautiful curve (the y axis is normalized, so that the highest number of sums reaches the same height in each graph):

Graph for sums from 1 binary digit


Graph for sums from 2 binary digits


Graph for sums from 3 binary digits


Graph for sums from 4 binary digits


Graph for sums from 5 binary digits


Graph for sums from 6 binary digits


Graph for sums from 7 binary digits


Graph for sums from 8 binary digits


Graph for sums from 9 binary digits


Graph for sums from 10 binary digits


Graph for sums from 11 binary digits


Graph for sums from 12 binary digits


Graph for sums from 13 binary digits


Graph for sums from 14 binary digits


Graph for sums from 15 binary digits


Graph for sums from 16 binary digits


Graphs for 1 to 16 binary digits (animated)


You may recognize the shape emerging above as the bell curve, whose formula is this:

Formula for the normal distribution or bell curve (image from ThoughtCo)


And that’s how you can find pi in the bi, or π in the binary digits of 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101…


Post-Performative Post-Scriptum

I asked this question above: What could be simpler than using only two digits? Well, using only one digit is simpler still:


1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111...

But I don’t see an easy way to find π and e in numbers like that.

Primal Stream

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

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

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


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

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

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

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

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


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

You Sixy Beast

666 is the Number of the Beast. But it’s much more than that. After all, it’s a number, so it has mathematical properties (everything has mathematical properties, but it’s a sine-qua-non of numbers). For example, 666 is a palindromic number, reading the same forwards and backwards. And it’s a repdigit, consisting of a single repeated digit. Now try answering this question: how many pebbles are there in this triangle?



••
•••
••••
•••••
••••••
•••••••
••••••••
•••••••••
••••••••••
•••••••••••
••••••••••••
•••••••••••••
••••••••••••••
•••••••••••••••
••••••••••••••••
•••••••••••••••••
••••••••••••••••••
•••••••••••••••••••
••••••••••••••••••••
•••••••••••••••••••••
••••••••••••••••••••••
•••••••••••••••••••••••
••••••••••••••••••••••••
•••••••••••••••••••••••••
••••••••••••••••••••••••••
•••••••••••••••••••••••••••
••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••••
•••••••••••••••••••••••••••••••••••
••••••••••••••••••••••••••••••••••••


Counting the pebbles one by one would take a long time, but there’s a short-cut. Each line of the triangle after the first is one pebble longer than the previous line. There are 36 lines and therefore 36 pebbles in the final line. So the full number of pebbles = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36. And there’s an easy formula for that sum: (36^2 + 36) / 2 = (1296 + 36) / 2 = 1332 / 2 = 666.

So 666 is the 36th triangular number:


1 = 1
1+2 = 3
1+2+3 = 6
1+2+3+4 = 10
1+2+3+4+5 = 15
1+2+3+4+5+6 = 21
1+2+3+4+5+6+7 = 28
1+2+3+4+5+6+7+8 = 36
1+2+3+4+5+6+7+8+9 = 45
1+2+3+4+5+6+7+8+9+10 = 55
[...]
1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36 = 666

But what’s tri(666), the 666th triangular number? By the formula above, it equals (666^2 + 666) / 2 = (443556 + 666) / 2 = 444222 / 2 = 222111. But recall something else from above: tri(6) = 1+2+3+4+5+6 = 21. Is it a coincidence that tri(6) = 21 and tri(666) = 222111? No, it isn’t:


tri(6) = 21 = (6^2 + 6) / 2 = (36 + 6) / 2 = 42 / 2
tri(66) = 2211 = (66^2 + 66) / 2 = (4356 + 66) / 2 = 4422 / 2
tri(666) = 222111 = (666^2 + 666) / 2 = (443556 + 666) / 2 = 444222 / 2
tri(6666) = 22221111
tri(66666) = 2222211111
tri(666666) = 222222111111
tri(6666666) = 22222221111111
tri(66666666) = 2222222211111111
tri(666666666) = 222222222111111111
tri(6666666666) = 22222222221111111111
tri(66666666666) = 2222222222211111111111
tri(666666666666) = 222222222222111111111111
tri(6666666666666) = 22222222222221111111111111
tri(66666666666666) = 2222222222222211111111111111
tri(666666666666666) = 222222222222222111111111111111

So we’ve looked at tri(36) = 666 and tri(666) = 222111. Let’s go a step further: tri(222111) = 24666759216. So 666 appears again. And the sixiness carries on here:


tri(36) = 666
tri(3366) = 5666661
tri(333666) = 55666666611
tri(33336666) = 555666666666111
tri(3333366666) = 5555666666666661111
tri(333333666666) = 55555666666666666611111
tri(33333336666666) = 555555666666666666666111111
tri(3333333366666666) = 5555555666666666666666661111111
tri(333333333666666666) = 55555555666666666666666666611111111
tri(33333333336666666666) = 555555555666666666666666666666111111111
tri(3333333333366666666666) = 5555555555666666666666666666666661111111111
tri(333333333333666666666666) = 55555555555666666666666666666666666611111111111
tri(33333333333336666666666666) = 555555555555666666666666666666666666666111111111111
tri(3333333333333366666666666666) = 5555555555555666666666666666666666666666661111111111111
tri(333333333333333666666666666666) = 55555555555555666666666666666666666666666666611111111111111

Agogic Arithmetic

This is one of my favorite integer sequences:

• 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, ... — A000217 at OEIS



And it’s easy to work out the rule that generates the sequence. It’s the sequence of triangular numbers, of course, which you get by summing the integers:

1
1 + 2 = 3
3 + 3 = 6
6 + 4 = 10
10 + 5 = 15
15 + 6 = 21
21 + 7 = 28
28 + 8 = 36
36 + 9 = 45
[...]


I like this sequence too, but it isn’t a sequence of integers and it’s much harder to work out the rule that generates it:

• 1, 3/2, 11/6, 25/12, 137/60, 49/20, 363/140, 761/280, 7129/2520, 7381/2520, 83711/27720, 86021/27720, 1145993/360360, 1171733/360360...


But you could say that it’s the inverse of the triangular numbers, because you generate it like this:

1
1 + 1/2 = 3/2
3/2 + 1/3 = 11/6
11/6 + 1/4 = 25/12
25/12 + 1/5 = 137/60
137/60 + 1/6 = 49/20
49/20 + 1/7 = 363/140
363/140 + 1/8 = 761/280
761/280 + 1/9 = 7129/2520
[...]

It’s the harmonic series, which is defined at Wikipedia as “the infinite series formed by summing all positive unit fractions”. I can’t understand its subtleties or make any important discoveries about it, but I thought I could ask (and begin to answer) a question that perhaps no-one else in history had ever asked: When are the leading digits of the k-th harmonic number, hs(k), equal to the digits of k in base 10?

hs(1) = 1
hs(43) = 4.349...
hs(714) = 7.1487...
hs(715) = 7.1501...
hs(9763) = 9.76362...
hs(122968) = 12.296899...
hs(122969) = 12.296907...
hs(1478366) = 14.7836639...
hs(17239955) = 17.23995590...
hs(196746419) = 19.6746419...
hs(2209316467) = 22.0931646788...


Do those numbers have any true mathematical significance? I doubt it. But they were fun to find, even though I wasn’t the first person in history to ask about them:

• 1, 43, 714, 715, 9763, 122968, 122969, 1478366, 17239955, 196746419, 2209316467, 24499118645, 268950072605 — A337904 at OEIS, Numbers k such that the decimal expansion of the k-th harmonic number starts with the digits of k, in the same order.

Strange “S” in the Light

Unexpected discoveries are one of the joys of mathematics, even for amateurs. And computers help you make more of them, because computers make it easy to adjust variables or search faster and further through math-space than any unaided human ever could (on the downside, computers can make you lazy and blunt your intuition). Here’s an unexpected discovery I made using a computer in November 2020:

A distorted and dissected capital “S”


It’s a strange “S” that looks complex but is constructed very easily from three simple lines. And it’s a fractal, a shape that contains copies of itself at smaller and smaller scales:

Five sub-fractals of the Strange “S”


Elsewhere Other-Accessible…

Fractangular Frolics — the Strange “S” in more light

We Can Circ It Out

It’s a pretty little problem to convert this triangular fractal…

Sierpiński triangle (Wikipedia)


…into its circular equivalent:

Sierpiński triangle as circle


Sierpiński triangle to circle (animated)


But once you’ve circ’d it out, as it were, you can easily adapt the technique to fractals based on other polygons:

T-square fractal (Wikipedia)

T-square fractal as circle


T-square fractal to circle (animated)


Elsewhere other-accessible…

Dilating the Delta — more on converting polygonic fractals to circles…

The Devil’s Digits

As I’ve said before, I love the way that numbers can come in many different guises. For example, take the number 21. It comes in all these guises:

21 = 10101 in base 2 = 210 in base 3 = 111 in b4 = 41 in b5 = 33 in b6 = 30 in b7 = 25 in b8 = 23 in b9 = 21 in b10 = 1A in b11 = 19 in b12 = 18 in b13 = 17 in b14 = 16 in b15 = 15 in b16 = 14 in b17 = 13 in b18 = 12 in b19 = 11 in b20 = 10 in b21

But I’ve not chosen 21 at random. If you sum the 1s in the representations of 21 in bases 2 to 21, look what you get:

21 = 10101 in base 2 = 210 in base 3 = 111 in b4 = 41 in b5 = 33 in b6 = 30 in b7 = 25 in b8 = 23 in b9 = 21 in b10 = 1A in b11 = 19 in b12 = 18 in b13 = 17 in b14 = 16 in b15 = 15 in b16 = 14 in b17 = 13 in b18 = 12 in b19 = 11 in b20 = 10 in b21


21 = 1s=101s=201s=3 in base 2 = 21s=40 in base 3 = 111s=7 in b4 = 41s=8 in b5 = 33 in b6 = 30 in b7 = 25 in b8 = 23 in b9 = 21s=9 in b10 = 1s=10A in b11 = 1s=119 in b12 = 1s=128 in b13 = 1s=137 in b14 = 1s=146 in b15 = 1s=155 in b16 = 1s=164 in b17 = 1s=173 in b18 = 1s=182 in b19 = 11s=20 in b20 = 1s=210 in b21


In other words, 21 = digcount(21,dig=1,base=2..21). But n = digcount(n,dig,b=2..n) doesn’t happen for any other digit and doesn’t happen often with 1:

3 = digcount(3,d=1,b=2..3) = 11 in b2 = 10 in b3
4 = digcount(4,d=1,b=2..4) = 100 in b2 = 11 in b3 = 10 in b4
6 = digcount(6,d=1,b=2..6) = 110 in b2 = 20 in b3 = 12 in b4 = 11 in b5 = 10 in b6
10 = digcount(10,d=1) = 1010 in b2 = 101 in b3 = 22 in b4 = 20 in b5 = 14 in b6 = 13 in b7 = 12 in b8 = 11 in b9 = 10 in b10
15 = digcount(15,d=1) = 1111 in b2 = 120 in b3 = 33 in b4 = 30 in b5 = 23 in b6 = 21 in b7 = 17 in b8 = 16 in b9 = 15 in b10 = 14 in b11 = 13 in b12 = 12 in b13 = 11 in b14 = 10 in b15
21 = digcount(21,d=1) = 10101 in b2 = 210 in b3 = 111 in b4 = 41 in b5 = 33 in b6 = 30 in b7 = 25 in b8 = 23 in b9 = 21 in b10 = 1A in b11 = 19 in b12 = 18 in b13 = 17 in b14 = 16 in b15 = 15 in b16 = 14 in b17 = 13 in b18 = 12 in b19 = 11 in b20 = 10 in b21


After that, the digcount(n,d=1,b=2..n) → n/2 (see “Digital Dissection” for further discussion). But I decided to look for the first n where digcount(n,dig,b=2..n) = 666:

digcount(1270,1) = 666
digcount(3770,2) = 666
digcount(7667,3) = 666
digcount(12184,4) = 666
digcount(18845,5) = 666
digcount(25806,6) = 666
digcount(34195,7) = 666
digcount(43352,8) = 666
digcount(54693,9) = 666


It doesn’t stop there, of course. You can carry on for ever, looking for digcount(n,A) = 666, digcount(n,B) = 666, digcount(n,C) = 666, where A = 10, B = 11 and C=12, and so on. But it doesn’t start there, either. What about digcount(n,0) = 666? That isn’t easy to find, because 0 usually occurs far less often than other digits in the representation of n. Here are the integers setting records for digcount(n,0,b=2..n):

2 → digcount(2,0) = 1 ← 2= 10 in base 2
4 → digcount(4,0) = 3; ← 4 = 100 in base 2, 11 in base 3, 10 in base 4
8 → digcount(8,0) = 5 ← 8 = 1000 in base 2, 22 in base 3, 20 in base 4, 13 in base 5, 12 in base 6, 11 in base 7, 10 in base 8
12 → digcount(12,0) = 6
16 → digcount(16,0) = 8
18 → digcount(18,0) = 9
32 → digcount(32,0) = 11
36 → digcount(36,0) = 13
64 → digcount(64,0) = 15
72 → digcount(72,0) = 18
128 → digcount(128,0) = 20
144 → digcount(144,0) = 24
252 → digcount(252,0) = 25
264 → digcount(264,0) = 27
288 → digcount(288,0) = 29
360 → digcount(360,0) = 30
504 → digcount(504,0) = 33
540 → digcount(540,0) = 36
720 → digcount(720,0) = 40
900 → digcount(900,0) = 42
1080 → digcount(1080,0) = 47
1680 → digcount(1680,0) = 48
1800 → digcount(1800,0) = 53
2160 → digcount(2160,0) = 56
2520 → digcount(2520,0) = 61
3600 → digcount(3600,0) = 64
4320 → digcount(4320,0) = 66


So what is the first n for which digcount(n,0) = 666? Watch this space.