login
A175945
Start with the binary expansion of n; list the lengths of the runs of ones and interpret this list as lengths of runs of alternating ones and zeros in binary.
5
1, 1, 3, 1, 2, 3, 7, 1, 2, 2, 4, 3, 6, 7, 15, 1, 2, 2, 4, 2, 5, 4, 8, 3, 6, 6, 12, 7, 14, 15, 31, 1, 2, 2, 4, 2, 5, 4, 8, 2, 5, 5, 11, 4, 9, 8, 16, 3, 6, 6, 12, 6, 13, 12, 24, 7, 14, 14, 28, 15, 30, 31, 63, 1, 2, 2, 4, 2, 5, 4, 8, 2, 5, 5, 11, 4, 9, 8, 16, 2, 5, 5, 11, 5, 10, 11, 23, 4, 9, 9, 19, 8, 17
OFFSET
1,3
COMMENTS
Trailing binary zeros don't affect the run lengths of 1's, so a(2n)=a(n). Trailing isolated binary ones add a run of a single 1, so a(4n+1) = 2*a(n) if a(n) is odd, a(4n+1) = 2*a(n)+1 if a(n) is even. - R. J. Mathar, Dec 07 2010
EXAMPLE
n=43 in binary is 101011, where the 1 has run-lengths of 1, 1 and 2. This is interpreted as a run of 1 one, run of 1 zero and run of 2 one's, 1011, which back to decimal is a(43)=11. - R. J. Mathar, Dec 07 2010
MATHEMATICA
takelist[l_, t_] := Module[{lent, term}, Set[lent, Length[t]]; Table[l[[t[[y]]]], {y, 1, lent}]]
frombinrep[x_] := FromDigits[Flatten[Table[Table[If[OddQ[n], 1, 0], {d, 1, x[[n]]}], {n, 1, Length[x]}]], 2]
binrep[x_] := repcount[IntegerDigits[x, 2]]
onebinrep[x_]:=Module[{b}, b=binrep[x]; takelist[b, Range[1, Length[b], 2]]]
zerobinrep[x_]:=Module[{b}, b=binrep[x]; takelist[b, Range[2, Length[b], 2]]]
Table[frombinrep[onebinrep[n]], {n, START, END}]
CROSSREFS
Sequence in context: A087227 A060477 A345037 * A209859 A354092 A262218
KEYWORD
base,easy,nonn
AUTHOR
Dylan Hamilton, Oct 28 2010
EXTENSIONS
Definition rewritten by N. J. A. Sloane, Dec 08 2010.
STATUS
approved