%I #82 Jan 23 2023 02:32:52
%S 1,1,2,1,2,3,4,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
%T 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
%U 27,28,29,30,31,32,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
%N n-th chunk consists of the numbers 1, ..., 2^n.
%C a(k) is the distance between k and the largest power of 2 not exceeding k, where k = n + 1. [Consider the sequence of even numbers <= k; after sending the first term to the last position delete all odd-indexed terms; the final term that remains after iterating the process is the a(k)-th even number.] - _Lekraj Beedassy_, May 26 2005
%C Triangle read by rows in which row n lists the first 2^(n-1) positive integers, n >= 1; see the example. - _Omar E. Pol_, Sep 10 2013
%H Reinhard Zumkeller, <a href="/A062050/b062050.txt">Table of n, a(n) for n = 1..10000</a>
%H Paul Barry, <a href="https://arxiv.org/abs/2107.00442">Conjectures and results on some generalized Rueppel sequences</a>, arXiv:2107.00442 [math.CO], 2021.
%H Ralf Stephan, <a href="/somedcgf.html">Some divide-and-conquer sequences with (relatively) simple ordinary generating functions</a>, 2004.
%H Ralf Stephan, <a href="/A079944/a079944.ps">Table of generating functions</a>. [ps file]
%H Ralf Stephan, <a href="/A062050/a062050.pdf">Table of generating functions</a>. [pdf file]
%F a(n) = A053645(n) + 1.
%F a(n) = n - msb(n) + 1 (where msb(n) = A053644(n)).
%F a(n) = 1 + n - 2^floor(log(n)/log(2)). - _Benoit Cloitre_, Feb 06 2003; corrected by Joseph Biberstine (jrbibers(AT)indiana.edu), Nov 25 2008
%F G.f.: 1/(1-x) * ((1-x+x^2)/(1-x) - Sum_{k>=1} 2^(k-1)*x^(2^k)). - _Ralf Stephan_, Apr 18 2003
%F a(1) = 1, a(2*n) = 2*a(n) - 1, a(2*n+1) = 2*a(n). - _Ralf Stephan_, Oct 06 2003
%F A005836(a(n+1)) = A107681(n). - _Reinhard Zumkeller_, May 20 2005
%F a(n) = if n < 2 then n else 2*a(floor(n/2)) - 1 + n mod 2. - _Reinhard Zumkeller_, May 07 2012
%F Without the constant 1, _Ralf Stephan_'s g.f. becomes A(x) = x/(1-x)^2 - (1/(1-x)) * Sum_{k>=1} 2^(k-1)*x^(2^k)) and satisfies the functional equation A(x) - 2*(1+x)*A(x^2) = x*(1 - x - x^2)/(1 - x^2). - _Petros Hadjicostas_, Apr 27 2020
%F For n > 0: a(n) = (A006257(n) + 1) / 2. - _Frank Hollstein_, Oct 25 2021
%e From _Omar E. Pol_, Aug 31 2013: (Start)
%e Written as irregular triangle with row lengths A000079:
%e 1;
%e 1, 2;
%e 1, 2, 3, 4;
%e 1, 2, 3, 4, 5, 6, 7, 8;
%e 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16;
%e ...
%e Row sums give A007582.
%e (End)
%p A062050 := proc(n) option remember; if n < 4 then return [1, 1, 2][n] fi;
%p 2*A062050(floor(n/2)) + irem(n,2) - 1 end:
%p seq(A062050(n), n=1..89); # _Peter Luschny_, Apr 27 2020
%t Flatten[Table[Range[2^n],{n,0,6}]] (* _Harvey P. Dale_, Oct 12 2015 *)
%o (PARI) a(n)=floor(n+1-2^floor(log(n+1-10^-27)/log(2)))
%o (Haskell)
%o a062050 n = if n < 2 then n else 2 * a062050 n' + m - 1
%o where (n',m) = divMod n 2
%o -- _Reinhard Zumkeller_, May 07 2012
%o (Python)
%o def A062050(n): return n-(1<<n.bit_length()-1)+1 # _Chai Wah Wu_, Jan 22 2023
%Y Cf. A053644, A053645.
%Y Cf. A092754.
%K nonn
%O 1,3
%A _Marc LeBrun_, Jun 30 2001