%I
%S 3,4,2,4,7,12,9,8,21,12,15,15,30,16,30,40,35,60,21,57,24,24,90,63,27,
%T 28,12,12,31,220,33,63,180,420,37,225,39,24,182,99,60,40,306,264,195,
%U 48,49,60,51,144,306,84,462,60,264,265,180,240,35,35,63,144,612,544,67,1012,870,84,840,72,195,264,180,312,650,1023,79,180,81,228,63,84,1740,783,87,88
%N The number of "topped inward" shuffles to reorder a stack of n cards to its original order.
%C Define a shuffle where the top of the old stack becomes the top of the new stack and is "marked" such that the 2nd, 3rd, 4th card of the old stack are placed right after, just before, right after, just before,... the position of the marked card in the new stack.
%C This permutes the numbers 1, 2, 3, 4, 5.. > 1 > 1,2 > 3,1,2 > 3,1,4,2 > 3,5,1,4,2 etc. Compared to the shuffle in A238371, the odd numbers before the 1 and even numbers after the 1 appear in the opposite order, (old) labels growing inwards towards the (old) top card.
%C (The "topped inward" classification is a nomenclature invented here; to be replaced by a better name once available.)
%C The sequence shows how often this shuffle needs to be applied to let the reshuffled stack return to its original 1, 2, 3,.. order.
%C Conjecture (equivalent to the Pfister comment in A216066): if the shuffle were defined again in inward order, but with the odd numbers to the left and the even numbers to the right, A003558 becomes the number of shuffles to return to original order.
%e For n=5, the shuffle of 1,2,3,4,5 is 3,5,1,4,2 (1st shuffle), which becomes 1,2,3,4,5 (2nd shuffle, already original order), so a(5)=2
%p trackIn := proc(L)
%p local ret,po,k ;
%p ret := [op(1,L)] ;
%p po := 1 ;
%p for k from 2 to nops(L) do
%p if type(k,'even') then
%p ret := [op(1..po,ret),op(k,L),op(po+1..nops(ret),ret)] ;
%p else
%p ret := [op(1..po1,ret),op(k,L),op(po..nops(ret),ret)] ;
%p po := po+1 ;
%p end if;
%p end do:
%p ret ;
%p end proc:
%p A238373 := proc(n)
%p local ca,org,tu ;
%p ca := [seq(k,k=1..n)] ;
%p org := [seq(k,k=1..n)] ;
%p for tu from 1 do
%p ca := trackIn(ca) ;
%p if ca = org then
%p return tu;
%p end if:
%p end do:
%p end proc:
%p seq(A238373(n),n=3..88)
%K nonn
%O 3,1
%A _R. J. Mathar_, Feb 25 2014
