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.

Showing 1-3 of 3 results.

A294673 Order of the "inside-out" permutation on 2n+1 letters.

Original entry on oeis.org

1, 3, 5, 4, 9, 11, 9, 5, 12, 12, 7, 23, 8, 20, 29, 6, 33, 35, 20, 39, 41, 28, 12, 36, 15, 51, 53, 36, 44, 24, 20, 7, 65, 36, 69, 60, 42, 15, 20, 52, 81, 83, 9, 60, 89, 60, 40, 95, 12, 99, 84, 66, 105, 28, 18, 37, 113, 30, 92, 119, 81, 36, 25, 8, 36, 131, 22, 135, 20, 30, 47, 60, 48, 116, 132, 100, 51, 155
Offset: 0

Views

Author

P. Michael Hutchins, Nov 06 2017

Keywords

Comments

The "inside-out" permutation (closely related to the Mongean shuffle, see A019567) sends (t_1, t_2, ..., t_{2n+1}) to (t_{n+1}, t_{n+2}, t_{n}, t_{n+3}, t_{n-1}, ..., t_1). For n = 0, 1, 2, 3, this is (1), (2,3,1), (3,4,2,5,1), (4,5,3,6,2,7,1), whose orders are respectively 1,3,5,4.
This is the odd bisection of A238371 and also the odd bisection of A003558 (see Joseph L. Wetherell's comment below).

Examples

			For n=2: Iterating the "inside-out" permutation of a string of length 2n+1=5:
12345
34251
25413
41532
53124
12345
...
which has order a(2) = 5.
		

Crossrefs

Programs

  • Magma
    f:=func;
    [f(n): n in [0..100]]; // Joseph L. Wetherell, Nov 12 2017
    
  • Magma
    [Order(Integers(4*n+3)!-2*(-1)^n): n in [0..100]]; // Joseph L. Wetherell, Nov 15 2017
  • Maple
    f:= proc(n)
      ilcm(op(map(nops,convert(map(op, [[n+1],seq([n+1+i,n+1-i],i=1..n)]),disjcyc))))
    end proc:
    map(f, [$0..100]); # Robert Israel, Nov 09 2017
  • Mathematica
    a[n_] := MultiplicativeOrder[-2(-1)^n, 4n+3];
    a /@ Range[0, 100] (* Jean-François Alcover, Apr 07 2020 *)
  • PARI
    Follow(s,f)={my(t=f(s),k=1); while(t>s, k++; t=f(t)); if(s==t, k, 0)}
    CyclePoly(n,x)={my(p=0); for(i=1, 2*n+1, my(l=Follow(i, j->n+1+(-1)^j*ceil((j-1)/2) )); if(l,p+=x^l)); p}
    a(n)={my(p=CyclePoly(n,x), m=1); for(i=1,poldegree(p),if(polcoeff(p,i), m=lcm(m,i))); m} \\ Andrew Howroyd, Nov 08 2017
    
  • PARI
    a(n)=znorder(Mod(if(n%2,2,-2),4*n+3)) \\ See Wetherell formula; Charles R Greathouse IV, Nov 15 2017
    

Formula

The permutation sends i (1 <= i <= 2n+1) to p(i) = n + 1 + f(i), where f(i) = (-1)^i*ceiling((i-1)/2).
a(n) = minimal k>0 such that p^k() = p^0().
a((A163778(n)-1)/2) = A163778(n). - Andrew Howroyd, Nov 11 2017.
From Joseph L. Wetherell, Nov 14 2017: (Start)
a(n) is equal to the order of multiplication-by-2 acting on the set of nonzero elements in (Z/(4n+3)Z), modulo the action of +-1. To be precise, identify i=1,2,...,2*n+1 with the odd representatives J=1,3,...,4*n+1 of this set, via the map J = 2*i-1. It is not hard to show that the induced permutation on the set of J values is given on integer representatives by J -> (4*n+3+J)/2 if i=(J+1)/2 is even and J -> (4*n+3-J)/2 if i=(J+1)/2 is odd. It follows that this induces the permutation J -> +-J/2 (mod 4*n+3), from which we immediately see that the order is as stated.
Note that the order of 2 acting on (Z/(4n+3)Z)/{+-1} is the same as the order of either 2 or -2 acting on (Z/(4n+3)Z), depending on which of these is a quadratic residue modulo 4n+3. Thus an equivalent (and often easier) way to compute a(n) is as the order of -2*(-1)^n acting on (Z/(4n+3)Z).
Among other things, the lower and upper bounds log_2(n) + 2 < a(n) <= 2*n+1 follow immediately.
(End)
It appears that the upper bound a(n) = 2n+1 occurs iff 2n+1 belongs to A163778 or equivalently iff n belongs to A294434. This almost (but not quite) follows from the above comments by Andrew Howroyd and Joseph L. Wetherell. - N. J. A. Sloane, Nov 16 2017

A238371 a(1)=1; for n > 1, a(n) = the number of "topped" Mongean shuffles to reorder a stack of n cards to its original order.

Original entry on oeis.org

1, 1, 3, 3, 5, 5, 4, 4, 9, 9, 11, 11, 9, 9, 5, 5, 12, 12, 12, 12, 7, 7, 23, 23, 8, 8, 20, 20, 29, 29, 6, 6, 33, 33, 35, 35, 20, 20, 39, 39, 41, 41, 28, 28, 12, 12, 36, 36, 15, 15, 51, 51, 53, 53, 36, 36, 44, 44, 24, 24, 20, 20, 7, 7, 65, 65, 36, 36, 69, 69, 60, 60, 42, 42, 15, 15, 20, 20, 52, 52, 81, 81, 83, 83, 9, 9, 60, 60
Offset: 1

Views

Author

R. J. Mathar, Feb 25 2014

Keywords

Comments

In the Mongean shuffle, the top card of the stack becomes the top of the new stack, the second of the old stack goes on top of the new stack, the third to the bottom of the new stack, alternating top and bottom of the new stack.
Here we define a shuffle where the top-bottom placements in the new stack alternate in the same way, but the second card of the old stack moves to the *bottom* of the stack.
A single shuffle is a permutation of 1, 2, 3, 4, 5, 6, ... -> ..., 7, 5, 3, 1, 2, 4, 6, ...
The fixed points, where n=a(n), seem to be in A163778.
(The "topped" classification is a nomenclature invented here, to be replaced if this variant appears elsewhere in the literature.)

Crossrefs

Cf. A019567 (Mongean shuffle), A294673 (a bisection).

Programs

  • Maple
    topMong := proc(L)
        ret := [op(1,L)] ;
        for k from 2 to nops(L) do
            if type(k,'even') then
                ret := [op(ret),op(k,L)] ;
            else
                ret := [op(k,L),op(ret)] ;
            end if;
        end do:
        ret ;
    end proc:
    A238371 := proc(n)
        local ca,org,tu ;
        ca := [seq(k,k=1..n)] ;
        org := [seq(k,k=1..n)] ;
        for tu from 1 do
            ca := topMong(ca) ;
            if ca = org then
                return tu;
            end if:
        end do:
    end proc:
    seq(A238371(n),n=2..88) ;
  • Mathematica
    topMong[L_] := Module[{ret = {L[[1]]}}, For[k = 2, k <= Length[L], k++, If[ EvenQ[k], ret = Append[ret, L[[k]]], ret = Prepend[ret, L[[k]]]]]; ret];
    A238371[n_] := Module[{ca, org, tu}, ca = org = Range[n]; For[tu = 1, True, tu++, ca = topMong[ca]; If[ca == org, Return[tu]]]];
    Array[A238371, 88] (* Jean-François Alcover, Jul 03 2018, after R. J. Mathar *)
  • PARI
    apply( A238371(n)=znorder(Mod(bitand(n,2)*2-2,n\2*4+3)), [0..99]) \\ M. F. Hasler, Mar 31 2019

Formula

a(A163778(n)) = A163778(n). - Andrew Howroyd, Nov 11 2017

A145787 Number of times you have to move n cards from one pile to another doing one up, one down, until you obtain the initial sequence.

Original entry on oeis.org

1, 2, 2, 3, 3, 6, 6, 4, 4, 6, 6, 10, 10, 14, 14, 5, 5, 18, 18, 10, 10, 12, 12, 21, 21, 26, 26, 9, 9, 30, 30, 6, 6, 22, 22, 9, 9, 30, 30, 27, 27, 8, 8, 11, 11, 10, 10, 24, 24, 50, 50, 12, 12, 18, 18, 14, 14, 12, 12, 55, 55, 50, 50, 7, 7, 18, 18, 34, 34, 46, 46
Offset: 1

Views

Author

Hernan Bonsembiante (hernanbon(AT)tutopia.com), Oct 19 2008

Keywords

Comments

Let's say you have 3 cards (1 - 2 - 3). You move 1, 2 over 1, 3 below 2. Now you have: (2-1-3). Now you repeat the movement: You move 2, 1 over 2, 3 below 2. Now you have: (1-2-3). The same initial scenario. Total 2 moves. With 4 cards you do it in three moves. For 8 cards you need 4 moves. For 16 cards you need 5 moves. I can assume that for 32 cards I will do it in 6 moves. But for 14 or 15 cards you need 14 moves. I don't know how to predict how many moves for n cards...

Crossrefs

Cf. A019567.

Programs

  • Mathematica
    A019567[n_]:=For[m=1,True,m++,If[AnyTrue[{-1,1},Divisible[2^m+#,4n+1]&],Return[m]]]; (* from A019567 *)
    Table[A019567[Floor[n/2]],{n,80}] (* Jon Maiga, Oct 06 2019 *)
  • PARI
    deck(n) = {s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,;:!?.*%$£€=+-&()[]{}_"; v = Vec(s); ss = ""; for (i=1, n, ss = concat(ss, v[i]);); return (ss);}
    move(cards) = {v = Vec(cards); s = ""; for (i=1, length(v), if (i % 2, s = concat(s, v[i]), s = concat(v[i], s));); return (s);}
    a(n) = {cardsa = deck(n); cardsb = cardsa; diff = 1; nb = 0; while (diff, cardsb = move(cardsb); diff = (cardsa != cardsb); nb++;); return (nb);}
    \\ Michel Marcus, Mar 05 2013

Formula

a(n) = A019567(floor(n/2)). - Jon Maiga, Oct 06 2019

Extensions

More terms from Michel Marcus, Mar 05 2013
Showing 1-3 of 3 results.