cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A323712 Number of the following described shuffles required to return a deck of n cards to its original state. Create two piles by alternating a card from the top of the deck left-right-left-right until the deck is exhausted. Then, placing the left pile on top of the right pile constitutes one shuffle.

This page as a plain text file.
%I A323712 #25 Aug 02 2024 09:27:46
%S A323712 1,1,3,4,4,6,6,3,9,5,5,12,12,4,12,8,8,9,9,6,6,22,22,20,20,9,27,28,28,
%T A323712 10,10,5,15,12,12,36,36,12,12,20,20,7,7,12,36,46,46,42,42,8,24,52,52,
%U A323712 20,20,9,9,29,29,60,60,6,18,12,12,33,33,22,66,70,70,18
%N A323712 Number of the following described shuffles required to return a deck of n cards to its original state. Create two piles by alternating a card from the top of the deck left-right-left-right until the deck is exhausted. Then, placing the left pile on top of the right pile constitutes one shuffle.
%C A323712 The card shuffling procedure is the same for even n and odd n.
%C A323712 Here are a few conjectures.
%C A323712 a(n) <= n for all n.
%C A323712 a(p)=a(p-1) and a(p)|p-1 when p is a prime >= 5.
%C A323712 a(n)=a(n-1) and a(n)|n-1 for nonprimes 341=31*11 and 22369621=8191*2731 and probably other pseudoprimes of the form p*((p+2)/3) where p is a Mersenne prime and (p+2)/3 is prime.
%C A323712 n cards are returned to their original state after n shuffles when n=1, 3, 4, 6, 9, 12, 22, 27, 28, 36, 46, 52, 60, 70, 78, 81, ... (A373461) . These values of n are either of the form p-1 where p is an odd prime number or 3^i, i >= 0.
%C A323712 a(c) is relatively small (compared with nearby values) when c is a Catalan number.
%C A323712 a(2n+1)=3*a(2n) or a(2n+1)=a(2n) for all n.
%H A323712 Alois P. Heinz, <a href="/A323712/b323712.txt">Table of n, a(n) for n = 1..1024</a>
%F A323712 a(2^m) = m if m is odd, a(2^m) = 2m if m is even. - _Alois P. Heinz_, Feb 15 2019
%e A323712 For n=4, {a1,a2,a3,a4}-->{a3,a1,a4,a2}-->{a4,a3,a2,a1}-->{a2,a4,a1,a3}-->{a1,a2,a3,a4}, so a(4)=4.
%e A323712 For n=5, {a1,a2,a3,a4,a5}-->{a5,a3,a1,a4,a2}-->{a2,a1,a5,a4,a3}-->{a3,a5,a2,a4,a1}-->{a1,a2,a3,a4,a5}, so a(5)=4.
%p A323712 pileShuf := proc(L::list)
%p A323712     local i,n,shf ;
%p A323712     shf := [] ;
%p A323712     n := nops(L) ;
%p A323712     if type(n,'odd') then
%p A323712         for i from n to 1 by -2 do
%p A323712             shf := [op(shf),op(i,L)] ;
%p A323712         end do:
%p A323712         for i from n-1 to 2 by -2 do
%p A323712             shf := [op(shf),op(i,L)] ;
%p A323712         end do:
%p A323712     else
%p A323712         for i from n-1 to 1 by -2 do
%p A323712             shf := [op(shf),op(i,L)] ;
%p A323712         end do:
%p A323712         for i from n to 2 by -2 do
%p A323712             shf := [op(shf),op(i,L)] ;
%p A323712         end do:
%p A323712     end if;
%p A323712     shf ;
%p A323712 end proc:
%p A323712 A323712 := proc(n)
%p A323712     local L,itr,isord,i;
%p A323712     L := [seq(i,i=1..n)] ;
%p A323712     for itr from 1 to n! do
%p A323712         L := pileShuf(L) ;
%p A323712         isord := true ;
%p A323712         for i from 1 to nops(L) do
%p A323712             if op(i,L) <> i then
%p A323712                 isord := false ;
%p A323712                 break ;
%p A323712             end if;
%p A323712         end do:
%p A323712         if isord then
%p A323712             return itr ;
%p A323712         end if;
%p A323712     end do:
%p A323712     -1 ;
%p A323712 end proc:
%p A323712 seq(A323712(n),n=1..50) ; # _R. J. Mathar_, Aug 02 2024
%o A323712 (PARI) perm(n, vn) = {my(va = List(), vb = List()); for (k=1, n, if (k % 2, listput(va, vn[k]), listput(vb, vn[k]));); Vec(concat(Vecrev(va), Vecrev(vb)));}
%o A323712 a(n) = {my(vn = vector(n,k,k), vs = perm(n, vn), nb = 1); while (vs != vn, vs = perm(n, vs); nb++); nb;} \\ _Michel Marcus_, Feb 06 2019
%Y A323712 Cf. A024222, A022998, A163776, A373416 (fixed points).
%K A323712 nonn
%O A323712 1,3
%A A323712 _David Lovler_, Jan 24 2019