OFFSET
1,2
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..8192
FORMULA
From Rémy Sigrist, Jul 02 2019: (Begin)
a(2^k-1) = k for any k > 0.
a(2^k) = A004755(k) for any k > 0.
(End)
EXAMPLE
6 = 110, two runs, lengths 2 and 1, so we write down 101 and convert it to base 10, getting 5. So a(6) = 5.
MATHEMATICA
f[n_] := FromDigits[Flatten[IntegerDigits[Length /@ Split[IntegerDigits[n, \ 2]], 2]], 2]
Array[f, NUMBER OF TERMS]
PROG
(PARI) a(n) = my (b=[]); while (n, my (x=valuation(n+(n%2), 2)); b = concat(binary(x), b); n \= 2^x); fromdigits(b, 2) \\ Rémy Sigrist, Jul 02 2019
(Python)
from itertools import groupby
def a(n):
c = "".join(bin(len(list(g)))[2:] for k, g in groupby(bin(n)[2:]))
return int(c, 2)
print([a(n) for n in range(1, 75)]) # Michael S. Branicky, Oct 02 2021
CROSSREFS
KEYWORD
AUTHOR
Dylan Hamilton, Oct 23 2010
EXTENSIONS
Edited by N. J. A. Sloane, Oct 23 2010
STATUS
approved