OFFSET
1,2
COMMENTS
Obviously this compressed notation is useful only for n < 1023. A101211 is a version which works for all n.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..1022
EXAMPLE
n, binary, run lengths, -> a(n)
1, [1], [1] -> 1
2, [1, 0], [1, 1] -> 11
3, [1, 1], [2] -> 2
4, [1, 0, 0], [1, 2] -> 12
5, [1, 0, 1], [1, 1, 1] -> 111
6, [1, 1, 0], [2, 1] -> 21
7, [1, 1, 1], [3] -> 3
...
MATHEMATICA
Array[FromDigits@ Flatten[IntegerDigits@ Length[#] & /@ Split@ IntegerDigits[#, 2]] &, 40] (* Michael De Vlieger, Feb 17 2022 *)
PROG
(PARI) a(n) = { my (d=[], r); while (n, n\=2^r=valuation(n+n%2, 2); d=concat(digits(r), d)); fromdigits(d) } \\ Rémy Sigrist, Feb 17 2022
(Python)
from itertools import groupby
def A318927(n): return int(''.join(str(len(list(g))) for k, g in groupby(bin(n)[2:]))) # Chai Wah Wu, Mar 11 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Sep 09 2018
STATUS
approved