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.

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

This page as a plain text file.
%I A335835 #16 May 06 2025 11:22:28
%S A335835 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,
%T A335835 25,26,25,28,29,30,31,62,61,58,57,50,53,50,57,58,53,42,53,50,53,58,61,
%U A335835 60,57,50,51,50,53,50,57,56,57,58,57,60,61,62,63,126,125
%N A335835 Sort the run lengths in binary expansion of n in descending order (with multiplicities).
%C A335835 This sequence preserves the number of runs (A005811) and the length (A070939) of the binary representation of a number.
%H A335835 Rémy Sigrist, <a href="/A335835/b335835.txt">Table of n, a(n) for n = 0..8191</a>
%H A335835 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A335835 a(a(n)) = a(n).
%e A335835 For n = 72:
%e A335835 - the binary representation of 72 is "1001000",
%e A335835 - the corresponding run lengths are: 1, 2, 1, 3,
%e A335835 - in descending order: 3, 2, 1, 1,
%e A335835 - so the binary representation of a(72) is "1110010",
%e A335835 - and a(72) = 114.
%o A335835 (PARI) torl(n) = { my (rr=[]); while (n, my (r=valuation(n+(n%2), 2)); rr = concat(r, rr); n\=2^r); rr }
%o A335835 fromrl(rr) = { my (v=0); for (k=1, #rr, v = (v+(k%2))*2^rr[k]-(k%2)); v }
%o A335835 a(n) = { fromrl(vecsort(torl(n),,4)) }
%Y A335835 Cf. A005811, A037016 (fixed points), A070939, A101211, A335834.
%K A335835 nonn,base,look,easy
%O A335835 0,3
%A A335835 _Rémy Sigrist_, Jun 26 2020