OFFSET
0,3
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).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8191
Rémy Sigrist, Scatterplot of the first 2^20 terms
Rémy Sigrist, Scatterplot of (n-2^19, a(n)-2^19) for n = 2^19..2^20-1
Rémy Sigrist, PARI program for A337242
FORMULA
a(2^k-1) = 2^k-1 for any k >= 0.
EXAMPLE
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.
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 *)
PROG
(PARI) See Links section.
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Aug 21 2020
STATUS
approved