cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A318926 Take the binary expansion of n, starting with the least significant bit, and concatenate the lengths of the runs.

Original entry on oeis.org

1, 11, 2, 21, 111, 12, 3, 31, 121, 1111, 211, 22, 112, 13, 4, 41, 131, 1121, 221, 2111, 11111, 1211, 311, 32, 122, 1112, 212, 23, 113, 14, 5, 51, 141, 1131, 231, 2121, 11121, 1221, 321, 3111, 12111, 111111, 21111, 2211, 11211, 1311, 411, 42, 132, 1122, 222, 2112, 11112, 1212, 312, 33, 123
Offset: 1

Views

Author

N. J. A. Sloane, Sep 09 2018

Keywords

Comments

Obviously this compressed notation is useful only for n < 2047. A227736 is a version which works for all n. [Corrected by M. F. Hasler, Mar 12 2025]

Examples

			n, binary, run lengths, -> a(n)
1, [1], [1] -> 1
2, [0, 1], [1, 1] -> 11
3, [1, 1], [2] ->  2
4, [0, 0, 1], [2, 1] -> 21
5, [1, 0, 1], [1, 1, 1] -> 111
6, [0, 1, 1], [1, 2] -> 12
7, [1, 1, 1], [3] -> 3
8, [0, 0, 0, 1], [3, 1] ->  31,
...
From _M. F. Hasler_, Mar 12 2025: (Start)
For n = 1023 = 2^10-1, n = '1'*10 in binary, so there is only one run of length 10, whence a(n) = 10. This value cannot occur at any other index n.
For n = 1024 = 2^10, n = '1'+'0'*10 in binary, so the run lengths, from right to left, are [10, 1], whence a(n) = 101. The only other index n for which this value occurs is n = 2^101-1.
For n = 1025 = 2^10+1, n = '1'+'0'*9+'1' in binary, so a(n) = 191. This values occurs for the second time as a(n = 2^19), for the third time for a(n = 2^92-2), and for the 4th and last time as a(n = 2^191-1).
Similarly, a(1026) = 1181 appears for the second time at n = 2^19 + 1 = 524289;
  a(1027) = 281 occurs a 2nd, 3rd and 4th time at n = 2^28, (2^81-1)*2 and 2^281-1.
The first duplicate value occurs as a(2047 = 2^11-1) = 11 = a(2). (End)
		

Crossrefs

Cf. A227736 (run lengths in rows instead of concatenation), A101211 (rows in reverse order), A318927 (concatenation in reverse order).

Programs

  • Mathematica
    A318926[n_] := FromDigits[Flatten[IntegerDigits[Map[Length, Split[Reverse[IntegerDigits[n, 2]]]]]]];
    Array[A318926, 100] (* Paolo Xausa, Mar 16 2025 *)
  • PARI
    A318926(n)=eval(strjoin(Vecrev(A101211_row(n)))); \\ M. F. Hasler, Mar 11 2025
  • Python
    from itertools import groupby
    def A318926(n): return int(''.join(str(len(list(g))) for k, g in groupby(bin(n)[:1:-1]))) # Chai Wah Wu, Mar 11 2022
    

Extensions

More terms from M. F. Hasler, Mar 12 2025