%I #17 Jun 27 2018 16:03:09
%S 0,1,1,2,2,4,5,3,3,8,5,10,9,8,13,4,4,11,17,11,9,6,11,22,20,7,25,19,8,
%T 28,29,5,5,32,21,34,8,19,29,38,26,40,7,27,10,11,9,35,23,14,49,50,11,
%U 52,17,35,13,43,11,23,54,19,49,6,6,64,17,35,33,68,45,59,13,41,73,14,23,19,25
%N Consider the sequence: b(0) = n, and for k >= 1, b(k) = b(k-1)/2 if b(k-1) is even, otherwise b(k) = k-(b(k-1)+1)/2. Then a(n) = m, where m is the smallest index such that b(m) = 1.
%C The first occurrence of the numbers 0, 1, 2, 3, 4, ... is at indices 1, 2, 4, 8, 6, 7, 22, 26, 10, 13, 12, 18, 1366, 15, 50, 386, ..., . - _Robert G. Wilson v_
%H Robert G. Wilson v, <a href="/A137605/b137605.txt">Table of n, a(n) for n = 1..10000</a>.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Faro_shuffle">Faro shuffle</a>.
%F For n>2, if 2n-1 is in A014657, then a(n) = A002326(n-1)/2 - 1, otherwise a(n) = A002326(n-1) - 1. In particular, if A002326(n-1) is odd, then a(n) = A002326(n-1) - 1. - _Max Alekseyev_, May 21 2008, Dec 09 2017
%F For n>=2, a(n) = A003558(n+1) - 1. - _Joerg Arndt_, Sep 12 2013
%e 6->3->4->2->1. So a(6)=4.
%t f[n_] := Block[{lst = {n}, a}, While[a = lst[[ -1]]; a != 1, If[EvenQ@a, AppendTo[lst, a/2], AppendTo[lst, lst[[1]] - (a + 1)/2]]]; Length@ lst - 1]; Array[f, 79] (* _Robert G. Wilson v_ *)
%Y Cf. A137604, A003558.
%K nonn
%O 1,4
%A _Yasutoshi Kohmoto_, Apr 23 2008
%E More terms from _Robert G. Wilson v_, May 15 2008
%E Edited by _Max Alekseyev_, Dec 09 2017
|