%I #10 Aug 11 2020 01:25:28
%S 0,1,2,3,6,5,4,7,14,13,10,9,12,11,8,15,30,29,26,25,22,21,18,17,28,27,
%T 20,19,24,23,16,31,62,61,58,57,54,53,50,49,46,45,42,41,38,37,34,33,60,
%U 59,52,51,44,43,36,35,56,55,40,39,48,47,32,63,126,125,122
%N Left-rotate run-lengths of consecutive equal digits in binary representation of n.
%C This sequence is a permutation of the nonnegative integers, with inverse A336962.
%H Rémy Sigrist, <a href="/A336963/b336963.txt">Table of n, a(n) for n = 0..8191</a>
%H Rémy Sigrist, <a href="/A336963/a336963.png">Colored scatterplot of the first 2^16 terms</a> (where the color is function of A090996(n))
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(n) = n iff n = 0 or n belongs to A140690.
%e The first terms, in decimal and in binary, are:
%e n a(n) bin(n) bin(a(n))
%e -- ---- ------ ---------
%e 0 0 0 0
%e 1 1 1 1
%e 2 2 10 10
%e 3 3 11 11
%e 4 6 100 110
%e 5 5 101 101
%e 6 4 110 100
%e 7 7 111 111
%e 8 14 1000 1110
%e 9 13 1001 1101
%e 10 10 1010 1010
%e 11 9 1011 1001
%e 12 12 1100 1100
%e 13 11 1101 1011
%e 14 8 1110 1000
%e 15 15 1111 1111
%o (PARI) toruns(n) = { my (r=[]); while (n, my (v=valuation(n+n%2,2)); n\=2^v; r=concat(v,r)); r }
%o fromruns(r) = { my (v=0); for (k=1, #r, v=(v+k%2)*2^r[k]-k%2); v }
%o a(n) = { my (r=toruns(n)); fromruns(vector(#r, k, r[1+k%#r])) }
%Y Cf. A006257, A090996, A101211, A140690, A336962.
%K nonn,base
%O 0,3
%A _Rémy Sigrist_, Aug 09 2020