%I #23 Nov 29 2022 01:32:23
%S 0,2,2,4,4,2,2,8,8,2,2,4,4,2,2,16,16,2,2,4,4,2,2,8,8,2,2,4,4,2,2,32,
%T 32,2,2,4,4,2,2,8,8,2,2,4,4,2,2,16,16,2,2,4,4,2,2,8,8,2,2,4,4,2,2,64,
%U 64,2,2,4,4,2,2,8,8,2,2,4,4,2,2,16,16,2,2,4,4,2,2,8,8,2,2,4,4,2,2,32,32,2,2
%N Site swap sequence associated with the permutation A065174 of Z.
%C Here the site swap pattern ...,2,16,2,4,2,8,2,4,2,0,2,4,2,8,2,4,2,16,2,... that spans over the Z (zero throw is at t=0) has been folded to N by picking values at t=0, t=1, t=-1, t=2, t=-2, etc. successively.
%C This pattern is shown in the figure 7 of Buhler and Graham paper and uses infinitely many balls, with each ball at step t thrown always to constant "height" 2^A001511[abs(t)] (no balls in hands at step t=0).
%H Georg Fischer, <a href="/A065176/b065176.txt">Table of n, a(n) for n = 1..16384</a>
%H Joe Buhler and R. L. Graham, <a href="https://web.archive.org/web/20201107022100/http://www.cecm.sfu.ca/organics/papers/buhler/index.html">Juggling Drops and Descents</a>, Amer. Math. Monthly, 101, (no. 6) 1994, 507 - 519.
%F G.f.: (1-x+x^2)/(1-x) + (1+x)*Sum(k>=1, 2^(k-1)*x^2^k/(1-x^2^k)). - _Ralf Stephan_, Apr 17 2003
%F a(n) = A171977(floor(n/2)) for n >= 2. - _Georg Fischer_, Nov 28 2022
%p [seq(TZ2(abs(N2Z(n))), n=1..120)]; # using TZ2 from A065174
%p N2Z := n -> ((-1)^n)*floor(n/2); Z2N := z -> 2*abs(z)+`if`((z < 1),1,0);
%p # Alternative:
%p A065176 := n -> `if`(n = 1, 0, 2^padic:-ordp(n - 1 + irem(n-1, 2), 2)):
%p seq(A065176(n), n = 1..99); # _Peter Luschny_, Nov 14 2021
%o (PARI) a(n) = if(n==1,0, 1<<valuation(bitnegimply(n,1),2)); \\ _Kevin Ryde_, Jul 09 2021
%o (Python)
%o def A065176(n):
%o s, h = 1, n // 2
%o if 0 == h: return 0
%o while 0 == h % 2:
%o h //= 2
%o s += s
%o return s + s
%o print([A065176(n) for n in range(1, 100)]) # _Peter Luschny_, Nov 14 2021
%Y Bisection of this gives A171977 or 2*A006519 or 2^A001511.
%K easy,nonn
%O 1,2
%A _Antti Karttunen_, Oct 19 2001