OFFSET
1,2
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]
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..10000
Claude Lenormand, Deux transformations sur les mots, Preprint, 5 pages, Nov 17 2003. Apparently unpublished. This is a scanned copy of the version that the author sent to me in 2003. - N. J. A. Sloane, Sep 09 2018. See Procedure 1.
EXAMPLE
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)
MATHEMATICA
A318926[n_] := FromDigits[Flatten[IntegerDigits[Map[Length, Split[Reverse[IntegerDigits[n, 2]]]]]]];
Array[A318926, 100] (* Paolo Xausa, Mar 16 2025 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,base,changed
AUTHOR
N. J. A. Sloane, Sep 09 2018
EXTENSIONS
More terms from M. F. Hasler, Mar 12 2025
STATUS
approved