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.

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.

Original entry on oeis.org

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

Views

Author

Dylan Hamilton, Oct 28 2010

Keywords

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

Examples

			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
		

Programs

  • 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}]

Extensions

Definition rewritten by N. J. A. Sloane, Dec 08 2010.