%I #9 Oct 14 2019 14:31:24
%S 1,3,2,15,6,4,5,255,30,12,13,16,9,11,10,65535,510,60,61,48,25,27,26,
%T 256,33,19,18,47,22,20,21,4294967295,131070,1020,1021,240,121,123,122,
%U 768,97,51,50,111,54,52,53,65536,513,67,66,79,38,36,37,767,94,44,45
%N a(n) is the least k such that A175930(k) = n.
%C To compute a(n):
%C - the binary representation of n has k = A000120(n) one bits,
%C - the binary representation of a(n) has k runs of consecutive equal bits,
%C - the length of the i-th run in a(n) has length 2^z where z is the number of zeros immediately following the i-th one bit in the binary representation of n,
%C - this division into sections starting with ones in n or corresponding to a run in a(n) is materialized by slashes in the example section.
%F a(n) <= 2^n-1 with equality iff n is a power of 2.
%F A005811(a(n)) = A000120(n).
%e The first terms, alongside the binary representation of n and of a(n) with peer sections separated by slashes, are:
%e n a(n) bin(n) bin(a(n))
%e -- ----- ------- ----------------
%e 1 1 1 1
%e 2 3 10 11
%e 3 2 1/1 1/0
%e 4 15 100 1111
%e 5 6 10/1 11/0
%e 6 4 1/10 1/00
%e 7 5 1/1/1 1/0/1
%e 8 255 1000 11111111
%e 9 30 100/1 1111/0
%e 10 12 10/10 11/00
%e 11 13 10/1/1 11/0/1
%e 12 16 1/100 1/0000
%e 13 9 1/10/1 1/00/1
%e 14 11 1/1/10 1/0/11
%e 15 10 1/1/1/1 1/0/1/0
%e 16 65535 10000 1111111111111111
%o (PARI) a(n)={ my (r=[], l, v=0); while (n, r=concat(l=1+valuation(n,2), r); n \= 2^l); for (i=1, #r, v *= 2^2^(r[i]-1); if (i%2, v += 2^2^(r[i]-1)-1)); v }
%Y Cf. A000120, A005811, A175930.
%K nonn,base
%O 1,2
%A _Rémy Sigrist_, Oct 11 2019
|