login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A335834 Sort the run lengths in binary expansion of n in ascending order (with multiplicities). 3

%I #19 Jun 28 2020 16:20:30

%S 0,1,2,3,4,5,4,7,8,11,10,11,12,11,8,15,16,23,20,19,20,21,20,23,24,19,

%T 20,19,24,23,16,31,32,47,40,39,44,43,44,39,40,43,42,43,44,43,40,47,48,

%U 39,44,51,44,43,44,39,56,39,40,39,48,47,32,63,64,95,80,79

%N Sort the run lengths in binary expansion of n in ascending order (with multiplicities).

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

%H Rémy Sigrist, <a href="/A335834/b335834.txt">Table of n, a(n) for n = 0..8191</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(a(n)) = a(n).

%e For n = 72:

%e - the binary representation of 72 is "1001000",

%e - the corresponding run lengths are: 1, 2, 1, 3,

%e - in ascending order: 1, 1, 2, 3,

%e - so the binary representation of a(72) is "1011000",

%e - and a(72) = 88.

%t Array[FromDigits[Flatten@ MapIndexed[ConstantArray[Mod[First[#2], 2], #1] &, Sort[Length /@ Split[IntegerDigits[#, 2]]]], 2] &, 67] (* _Michael De Vlieger_, Jun 27 2020 *)

%o (PARI) torl(n) = { my (rr=[]); while (n, my (r=valuation(n+(n%2), 2)); rr = concat(r, rr); n\=2^r); rr }

%o fromrl(rr) = { my (v=0); for (k=1, #rr, v = (v+(k%2))*2^rr[k]-(k%2)); v }

%o a(n) = { fromrl(vecsort(torl(n))) }

%Y Cf. A005811, A037014 (fixed points), A070939, A101211, A335835.

%K nonn,base,look,easy

%O 0,3

%A _Rémy Sigrist_, Jun 26 2020

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 7 13:22 EDT 2024. Contains 375730 sequences. (Running on oeis4.)