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.

Showing 1-2 of 2 results.

A335835 Sort the run lengths in binary expansion of n in descending order (with multiplicities).

Original entry on oeis.org

0, 1, 2, 3, 6, 5, 6, 7, 14, 13, 10, 13, 12, 13, 14, 15, 30, 29, 26, 25, 26, 21, 26, 29, 28, 25, 26, 25, 28, 29, 30, 31, 62, 61, 58, 57, 50, 53, 50, 57, 58, 53, 42, 53, 50, 53, 58, 61, 60, 57, 50, 51, 50, 53, 50, 57, 56, 57, 58, 57, 60, 61, 62, 63, 126, 125
Offset: 0

Views

Author

Rémy Sigrist, Jun 26 2020

Keywords

Comments

This sequence preserves the number of runs (A005811) and the length (A070939) of the binary representation of a number.

Examples

			For n = 72:
- the binary representation of 72 is "1001000",
- the corresponding run lengths are: 1, 2, 1, 3,
- in descending order: 3, 2, 1, 1,
- so the binary representation of a(72) is "1110010",
- and a(72) = 114.
		

Crossrefs

Cf. A005811, A037016 (fixed points), A070939, A101211, A335834.

Programs

  • PARI
    torl(n) = { my (rr=[]); while (n, my (r=valuation(n+(n%2), 2)); rr = concat(r, rr); n\=2^r); rr }
    fromrl(rr) = { my (v=0); for (k=1, #rr, v = (v+(k%2))*2^rr[k]-(k%2)); v }
    a(n) = { fromrl(vecsort(torl(n),,4)) }

Formula

a(a(n)) = a(n).

A337242 a(n) is the greatest number m not yet in the sequence such that the binary expansions of m and of n have the same run lengths (up to order but with multiplicity).

Original entry on oeis.org

0, 1, 2, 3, 6, 5, 4, 7, 14, 13, 10, 11, 12, 9, 8, 15, 30, 29, 26, 27, 22, 21, 20, 23, 28, 25, 18, 19, 24, 17, 16, 31, 62, 61, 58, 59, 54, 53, 52, 57, 46, 45, 42, 43, 50, 41, 40, 47, 60, 55, 44, 51, 38, 37, 36, 49, 56, 39, 34, 35, 48, 33, 32, 63, 126, 125, 122
Offset: 0

Views

Author

Rémy Sigrist, Aug 21 2020

Keywords

Comments

This sequence has similarities with A331274; here we consider run lengths in binary expansions, there binary digits.
This sequence is a self-inverse permutation of the nonnegative numbers.
This sequence preserves the number of binary digits (A070939) and the number of runs in binary expansions (A005811).
This sequence has interesting graphical features (see Links section).

Examples

			For n = 7280:
- 7280 has binary expansion "1110001110000",
- the corresponding run lengths are: {3, 3, 3, 4},
- there are four numbers k with the same multiset of run lengths:
    k     bin(k)           run lengths
    ----  ---------------  -----------
    7224  "1110000111000"  {3, 4, 3, 3}
    7280  "1110001110000"  {3, 3, 3, 4}
    7288  "1110001111000"  {3, 3, 4, 3}
    7736  "1111000111000"  {4, 3, 3, 3}
- so a(7224) = 7736,
     a(7280) = 7288,
     a(7288) = 7280,
     a(7736) = 7224.
		

Crossrefs

Programs

  • Mathematica
    Nest[Function[{a, m}, Append[a, SelectFirst[m, FreeQ[a, #] &]]] @@ {#1, Sort[Map[FromDigits[Join @@ MapIndexed[ConstantArray[Boole[OddQ@ First[#2]], #1] &, #], 2] &, Permutations[Length /@ Split@ IntegerDigits[#2, 2]]], Greater]} & @@ {#, Length@ #} &, {0}, 66] (* Michael De Vlieger, Aug 22 2020 *)
  • PARI
    See Links section.

Formula

a(2^k-1) = 2^k-1 for any k >= 0.
Showing 1-2 of 2 results.