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.

User: Hong-Chang Wang

Hong-Chang Wang's wiki page.

Hong-Chang Wang has authored 10 sequences.

A276451 Number of 2-orbits of the cyclic group C_4 for a bi-colored square n X n grid with n squares of one color.

Original entry on oeis.org

0, 1, 2, 12, 30, 408, 1012, 17920, 45600, 1059380, 2730756, 78115884, 203235032, 6917206576, 18113945256, 714851008512, 1881039165696, 84449819514060, 223049005408900, 11225502116862880, 29736777118603962, 1658138369930988088, 4403069737450280832
Offset: 1

Keywords

Comments

For a definition and examples of this problem see the comment section of A276449.
The present sequence a(n) gives the number of 2-orbits of such 2-color boards with n squares of one color under C_4.

Examples

			n = 4: one of the two 2-orbits is (o white, + black)
+ o + o   o o o +
o o o o   + o o o
o o o o   o o o +
o + o +   + o o o,
and one can take the first one as a representative.
For n = 3 there are a(3) = 2 2-orbits, represented by
+ o o       o o o
o + o  and  + + +
o o +       o o o.
The orbit structure for n=3 is 1^0 2^2 4^20; see A276449(3) = 0, a(3) = 2, A276452(3) = 20.
For the 12 2-orbits for n=4, see the representatives given in the link.
		

Crossrefs

Programs

  • Mathematica
    Table[(Function[j, Binomial[2 j (j + Boole@ OddQ@ n), j]]@ Floor[n/2] - If[MemberQ[{2, 3}, #], 0, Function[i, Binomial[(2 i) (2 i + #), i]]@ Floor[n/4]] &@ Mod[n, 4])/2, {n, 23}] (* Michael De Vlieger, Sep 07 2016 *)
  • Python
    import math
    def nCr(n,r):
        f = math.factorial
        return f(n) / f(r) / f(n-r)
    # main program
    for j in range(101):
        i = j/2
        if j%2==0:
            b = nCr(2*i*i,i)
        else:
            b = nCr(2*i*(i+1),i)
        if j%4==0:
            c = nCr((j*j/4),(j/4))
        elif j%4==1:
            c = nCr(((j-1)/2)*((j-1)/2+1),((j-1)/4))
        else:
            c = 0
        print(str(j)+" "+str((b-c)/2))

Formula

a(n) = (binomial(2*i*i,i) - A276449(n))/2, for n = 2*i.
a(n) = (binomial(2*i*(i+1),i) - A276449(n))/2, for n = 2*i+1.

Extensions

Edited: Wolfdieter Lang, Oct 02 2016

A276454 a(n) = A276452(n) + A276451(n) + A276449(n).

Original entry on oeis.org

1, 2, 22, 464, 13302, 487152, 21475652, 1106550392, 65221981530, 4327577893800, 319187492622012, 25904823495240144, 2294089575287710984, 220132629099295901408, 22751391952803426496488, 2519687900505935894639088, 297684761086123702744203918
Offset: 1

Keywords

Comments

For a definition and examples of this problem see the comment section of A276449.
The present sequence {a(n)} gives the number of all orbits under C_4 of 2-colored n X n square grids with n squares of one color.
See A054772(n, k) for the table of these total C_4 orbit numbers for 2-colored grids with any number k from {0,1,...,n^2} of squares of one color. - Wolfdieter Lang, Oct 02 2016

Examples

			For n = 4 there are A276449(4) = 4 1-orbits, represented by
   + o o +   o + o o   o o + o   o o o o
   o o o o   o o o +   + o o o   o + + o
   o o o o   + o o o   o o o +   o + + o
   + o o +   o o + o   o + o o   o o o o  .
A276451(4) = 12 2-orbits: one of them is
   + o + o   o o o +
   o o o o   + o o o
   o o o o   o o o +
   o + o +   + o o o  ,
and one can take the first one as representative.
A276452(4) = 448 4-orbits: one of them is represented by
   + + + +
   o o o o
   o o o o
   o o o o .
The complete orbit structure for n=4 is 1^4 2^12 4^448, see A276449(4) = 4, A276451(4) = 12, A276452(4) = 448.
a(4) = 448 + 12 + 4 = 464.
A014062(4) = 448*4 + 12*2 + 4*1 = 1820.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := If[MemberQ[{2, 3}, #], 0, Function[i, Binomial[(2 i) (2 i + #), i]]@ Floor[n/4]] &@ Mod[n, 4];g[n_] := (Function[j, Binomial[2 j (j + Boole@ OddQ@ n), j]]@ Floor[n/2] - f@ n)/2; Table[(Binomial[n^2, n] - 2 g@ n - f@ n)/4 + (Function[j, Binomial[2 j (j + Boole@ OddQ@ n), j]]@ Floor[n/2] - f@ n)/2 + f@ n, {n, 17}] (* Michael De Vlieger, Sep 12 2016 *)
  • Python
    from math import comb as binomial
    for j in range(1, 20):
        t = binomial(j * j, j)
        i = j // 2
        if j % 2 == 0:
            d = binomial(2 * i * i, i)
        else:
            d = binomial(2 * i * (i + 1), i)
        a = (t - d) // 4
        if j % 4 == 0:
            c = binomial((j * j // 4), (j // 4))
        elif j % 4 == 1:
            c = binomial(((j - 1) // 2) * ((j - 1) // 2 + 1), ((j - 1) // 4))
        else:
            c = 0
        b = (d - c) // 2
        print(str(j) + " " + str(a + b + c))

Formula

a(n) = A276452(n) + A276451(n) + A276449(n) for n = 1, 2, 3, ...,
A014062(n) = A276452(n)*4 + A276451(n)*2 + A276449(n).
a(n) = A054772(n, 2), n >= 1. - Wolfdieter Lang, Oct 02 2016

Extensions

Edited by Wolfdieter Lang, Oct 02 2016

A276452 Number of 4-orbits of the cyclic group C_4 for a bi-colored square n X n grid with n squares of one color.

Original entry on oeis.org

0, 1, 20, 448, 13266, 486744, 21474640, 1106532352, 65221935740, 4327576834420, 319187489891256, 25904823417117120, 2294089575084464472, 220132629092378694832, 22751391952785312551232, 2519687900505221042995200, 297684761086121821704009432, 37370623083548749203599933004
Offset: 1

Keywords

Comments

For a definition and examples of this problem see the comment section of A276449. The present sequence a(n) gives the number of 4-orbits under C_4 of such 2-colored n X n grids with n squares of one color.

Examples

			a(2) = 1: the 4-orbit is
+ +   o +   o o   + o
o o   o +   + +   + o  ,
and one can take the first one as representative.
For n = 3 there are a(3) = 20 4-orbits, represented by
+ + +   + + o   + + o   + + o   + + o
o o o   + o o   o + o   o o +   o o o
o o o   o o o   o o o   o o o   + o o
--------------------------------------
+ + o   + + o   + o +   + o +   + o +
o o o   o o o   + o o   o + o   o o o
o + o   o o +   o o o   o o o   + o o
--------------------------------------
+ o +   + o o   + o o   + o o   + o o
o o o   + + o   + o +   + o o   + o o
o + o   o o o   o o o   o + o   o o +
--------------------------------------
+ o o   + o o   + o o   o + o   o + o
o + +   o + o   o o +   + + o   + o +
o o o   o + o   o + o   o o o   o o o .
--------------------------------------
The complete orbit structure for n=3 is 1^0 2^2 4^20, see A276449(3) = 0, A276451(3) = 2, a(3) = 20
		

Crossrefs

Programs

  • Mathematica
    f[n_] := If[MemberQ[{2, 3}, #], 0, Function[i, Binomial[(2 i) (2 i + #), i]]@ Floor[n/4]] &@ Mod[n, 4]; g[n_] := (Function[j, Binomial[2 j (j + Boole@ OddQ@ n), j]]@ Floor[n/2] - f@ n)/2; Table[(Binomial[n^2, n] - 2 g@ n - f@ n)/4, {n, 18}] (* Michael De Vlieger, Sep 07 2016 *)
  • Python
    import math
    def nCr(n,r):
        f = math.factorial
        return f(n) / f(r) / f(n-r)
    # main program
    for j in range(101):
        a = nCr(j*j,j)
        i = j/2
        if j%2==0:
            b = nCr(2*i*i,i)
        else:
            b = nCr(2*i*(i+1),i)
        print(str(j)+" "+str((a-b)/4))

Formula

a(n) = (A014062(n) - A276451(n)*2 - A276449(n))/4 for n = 1, 2, 3, ...

A276449 Number of 1-orbits of the cyclic group C_4 for a bi-colored square n X n grid with n squares of one color.

Original entry on oeis.org

1, 0, 0, 4, 6, 0, 0, 120, 190, 0, 0, 7140, 11480, 0, 0, 635376, 1028790, 0, 0, 75287520, 122391522, 0, 0, 11143364232, 18161699556, 0, 0, 1978369382080, 3230129794320, 0, 0, 409663695276000, 669741609663270, 0, 0, 96930293990660064, 158625578809472060
Offset: 1

Keywords

Comments

The old name was: Number of ways to choose n points from an n X n grid so that they have 90-degree rotational symmetry.
Consider a square n X n grid with n^2 squares. Each of the n^2 squares comes in two colors.
(E.g., an n X n chessboard with only two black fields, or a binary n X n matrix).
There are N(n) = binomial(n^2,n) = A014062(n) such 2-color grids. We are interested in configurations where n squares are colored in one way, say black, and the remaining ones stay white. Only colored grids modulo rotation around some axis perpendicular to the board through its center are of interest. These rotations represent the cyclic group C_4. Under C_4 operations R(90)^k, k=1..4, there will only be orbits of order 1 (colored grids invariant under R(90)^1, hence any rotation) order 2 (two different grids each not invariant under R(90)^1 but R(90)^2 operation, transforming into each other) and order 4 (four different grids each not invariant under R(90)^k for k=1,2,3, but under R(4)^4, transforming into each other). The orbit structure is denoted by 1^(e(n,1)) 2^(e(n,2)) 4^(e(n,4)) with e(n, 2^j) nonnegative integers for j=0,1,2. One has Sum_{j=0,1,2} 2^j*e(n,2^j) = N(n), and Sum_{j=0,1,2} e(n,2^j) which is the total number of orbits, given in A276454(n).
For example, one of the four 1-orbits of 4 X 4 board. (o) white, (+) black:
+ o o +
o o o o
o o o o
+ o o + ,
an example of a 2-orbit,
+ o + o o o o +
o o o o + o o o
o o o o o o o +
o + o + + o o o ,
an example of a 4-orbit,
+ + + + o o o + o o o o + o o o
o o o o o o o + o o o o + o o o
o o o o o o o + o o o o + o o o
o o o o o o o + + + + + + o o o .
The present sequence a(n) gives the number of 1-orbits of such 2-colored boards with n squares of one color under C_4.

Examples

			a(4) = 4, the arrangements are as follows:
   + o o +   o + o o   o o + o   o o o o
   o o o o   o o o +   + o o o   o + + o
   o o o o   + o o o   o o o +   o + + o
   + o o +   o o + o   o + o o   o o o o
a(5) = 6, the arrangements are as follows:
   + o o o +   o + o o o   o o + o o
   o o o o o   o o o o +   o o o o o
   o o + o o   o o + o o   + o + o +
   o o o o o   + o o o o   o o o o o
   + o o o +   o o o + o   o o + o o
   and
   o o o + o   o o o o o   o o o o o
   + o o o o   o + o + o   o O + o o
   O o + o o   o o + o o   o + + + o
   o o o o +   o + O + O   o o + o o
   o + o o o   o o o o o   o o o o o
reformatted - _Wolfdieter Lang_, Oct 02 2016
		

Crossrefs

Programs

  • Maple
    seq(op([binomial(2*i*(2*i+1),i),0,0,binomial(4*(i+1)^2,i+1)]),i=0..30); # Robert Israel, Sep 05 2016
  • Mathematica
    Table[If[MemberQ[{2, 3}, #], 0, Function[i, Binomial[(2 i) (2 i + #), i]]@ Floor[n/4]] &@ Mod[n, 4], {n, 37}] (* Michael De Vlieger, Sep 07 2016 *)
  • Python
    import math
    def nCr(n,r):
        f = math.factorial
        return f(n) / f(r) / f(n-r)
    # main program
    for j in range(101):
        if j%4 == 0:
            a = nCr((j*j/4),(j/4))
        elif j%4 == 1:
            a = nCr(((j-1)/2)*((j-1)/2+1),((j-1)/4))
        else:
            a = 0
        print(str(j)+" "+str(a))

Formula

a(n) = binomial((2*i)^2,i), for n = 4*i,
a(n) = binomial((2*i)*(2*i+1),i), for n = 4*i+1,
a(n) = 0, for others.

Extensions

Edited: New name. Old name as a comment. Text substantially changed. Wolfdieter Lang, Oct 02 2016

A273916 The Bingo-4 problem: minimal number of stones that must be placed on an infinite square grid to produce n groups of exactly 4 stones each. Groups consist of adjacent stones in a horizontal, vertical or diagonal line.

Original entry on oeis.org

0, 4, 7, 9, 11, 12, 12, 14, 15, 16, 16, 18, 19, 20, 22, 24
Offset: 0

Keywords

Comments

You are permitted to put 5 or more adjacent stones in a line, but cannot count them as a group.
Each pair of stones has at most one group that counts going through them. - David A. Corneth, Aug 01 2016
a(n) >= n and a(n+m) <= a(n) + a(m), e.g., a(16) <= a(10) + a(6) = 28. Placing stones in a 4 X k rectangular array shows that a(3k) <= 4(k+2). Fekete's subadditive lemma shows that 1 <= lim_{n->oo} a(n)/n <= 4/3 exists. - Chai Wah Wu, Jul 31 2016
Limit_{n->oo} a(n)/n = 1. See arXiv link. - Chai Wah Wu, Aug 25 2016

Examples

			From _M. F. Hasler_, Jul 30 2016: (Start)
One can get n=3 groups using a(3) = 9 stones (O) as follows:
   O O O O     The 3 groups are:
   . O O .     (1) the first line,
   . O . .     (2) the second column,
   O O . .     (3) the antidiagonal.
See the link for more examples. (End)
		

Crossrefs

See also the 4-trees-in-a-row orchard problem, A006065.

Extensions

Edited by N. J. A. Sloane, Jul 29 2016

A274136 a(n) = (n+1)*(2*n+2)!/(n+2).

Original entry on oeis.org

1, 16, 540, 32256, 3024000, 410572800, 76281004800, 18598035456000, 5762136335155200, 2211729098342400000, 1030334000462807040000, 572721601599913328640000, 374484928188990947328000000, 284562454970932936468070400000
Offset: 0

Author

Hong-Chang Wang, Jun 10 2016

Keywords

Comments

Sequence is inspired by A273889, A274119 and A273983.
Since Product_{i=0..n}(i*k+a) - Product_{i=0..n}(-i*k-b) ≡ 0 mod (n*k+a+b), then define B(n,k,a,b) = (Product_{i=0..n}(i*k+a) - Product_{i=0..n}(-i*k-b))/(n*k+a+b), with n*k+a+b <> 0, n >= 0 and k,a,b are integers, such that B(1,n,2,1) = (Product_{i=0..1}(i*n+2) - Product_{i=0..1}(-i*n-1))/(n+3) = A000012(n) with n >= 0;
B(3,n,2,1) = (Product_{i=0..3}(i*n+2) - Product_{i=0..3}(-i*n-1))/(3*n+3) = A100040(n+2) with n >= 0;
B(2*n+1,0,2,1) = (Product_{i=0..2*n+1}(2) - Product_{i=0..2*n+1}(-1))/3 = A002450(n+1) with n >= 0;
B(2*n+1,2,2,1) = (Product_{i=0..2*n+1}(2*i+2) - Product_{i=0..2*n+1}(-2*i-1))/(4*n+5) = A273983(n+1) with n >= 0;
and a(n) is B(2*n+1,1,2,1). - Hong-Chang Wang, Jun 17 2016

Examples

			a(0) = (2*3 - 1*2)/4 = 1.
a(1) = (2*3*4*5 - 1*2*3*4)/6 = 16.
a(2) = (2*3*4*5*6*7 - 1*2*3*4*5*6)/8 = 540.
		

Programs

  • Mathematica
    a[n_] := (Product[i + 2, {i, 0, 2*n + 1}] - Product[-i - 1, {i, 0, 2*n + 1}])/(2*n + 4); Table[a[n], {n, 0, 10}] (* G. C. Greubel, Jun 19 2016 *)
    Table[((n+1)(2n+2)!)/(n+2),{n,0,30}] (* Harvey P. Dale, Oct 24 2020 *)
  • PARI
    a(n) = ((2*n+1)!-(2*n)!)/(2*(n+1)) \\ Felix Fröhlich, Jun 11 2016
    
  • PARI
    a(n) = (prod(i=0, 2*n+1, i+2)-prod(i=0, 2*n+1, -i-1))/(2*n+4) \\ Felix Fröhlich, Jul 05 2016
  • Python
    # subroutine
    def B (n, k, a, b):
        pa = pb = 1
        for i in range(n+1):
            pa *= (i*k+a)
            pb *= (-i*k-b)
        m = n*k+a+b
        p = pa-pb
        if m == 0:
            return "NaN"
        else:
            return p/m
    # main program
    for j in range(101):
        print(str(j)+" "+str(B(2*j+1, 1, 2, 1)))  # Hong-Chang Wang, Jun 14 2016
    

Formula

a(n) = B(2*n+1,1,2,1) = (Product_{i=0..2*n+1}(i+2) - Product_{i=0..2*n+1}(-i-1))/(2*n+4), n >= 0.
a(n) = A062779(n)/(2*(n+1)). - Michel Marcus, Jun 11 2016
a(n) ~ sqrt(Pi)*exp(-2*n)*(48*n*(24*n + 13) + 1177)*4^(n-2)*n^(2*n+1/2)/9. - Ilya Gutkovskiy, Jul 07 2016

A274119 a(n) = (Product_{i=0..4}(i*n+2) - Product_{i=0..4}(-i*n-1))/(4*n+3).

Original entry on oeis.org

11, 120, 435, 1064, 2115, 3696, 5915, 8880, 12699, 17480, 23331, 30360, 38675, 48384, 59595, 72416, 86955, 103320, 121619, 141960, 164451, 189200, 216315, 245904, 278075, 312936, 350595, 391160, 434739, 481440, 531371, 584640
Offset: 0

Author

Hong-Chang Wang, Jun 10 2016

Keywords

Comments

Sequence is inspired by A273983. The same argument as in A273889 can be used here to prove the expression evaluates to an integer.
Since Product_{i=0..n}(i*k+a) - Product_{i=0..n}(-i*k-b) ≡ 0 mod (n*k+a+b), then define B(n,k,a,b) = (Product_{i=0..n}(i*k+a) - Product_{i=0..n}(-i*k-b))/(n*k+a+b), with n*k+a+b <> 0, n >= 0 and k,a,b are integers, such that B(2*n,2,2,1) = (Product_{i=0..2*n}(2*i+2) - Product_{i=0..2*n}(-2*i-1))/ (4*n+3) = A273889(n+1), n >= 0; B(2*n,3,2,1) = (Product_{i=0..2*n}(3*i+2) - Product_{i=0..2*n}(-3*i-1))/(6*n+3) = A274117(n+1), n >= 0; B(2,n,2,1) = (Product_{i=0..2}(i*n+2) - Product_{i=0..2}(-i*n-1))/(2*n+3) = A008585(n+1), n >= 0; and a(n) is B(4,n,2,1). - Hong-Chang Wang, Jun 17 2016

Examples

			a(0) = B(4,0,2,1) = (2*2*2*2*2 + 1*1*1*1*1)/3 = 11.
a(1) = B(4,1,2,1) = (2*3*4*5*6 + 1*2*3*4*5)/7 = 120.
a(2) = B(4,2,2,1) = (2*4*6*8*10 + 1*3*5*7*9)/11 = 435.
		

Crossrefs

Programs

  • Mathematica
    B[n_, k_] := (Product[k (i - 1) + 1, {i, 2 n - 1}] + Product[k (i - 1) + 2, {i, 2 n - 1}])/(2 k (n - 1) + 3); Table[B[3, n], {n, 0, 31}] (* Michael De Vlieger, Jun 10 2016 *)
  • Python
    # subroutine
    def B (n,k,a,b):
        pa = pb = 1
        for i in range(n+1):
            pa *= (i*k+a)
            pb *= (-i*k-b)
        m = n*k+a+b
        p = pa-pb
        if m == 0:
            return "NaN"
        else:
            return p/m
    # main program
    for j in range(101):
        print(str(j)+" "+str(B(4,j,2,1)))  # Hong-Chang Wang, Jun 14 2016

Formula

a(n) = B(4,n,2,1) = (Product_{i=0..4}(i*n+2) - Product_{i=0..4}(-i*n-1))/(4*n+3), n >= 0. - Hong-Chang Wang, Jun 14 2016
From Colin Barker, Jun 22 2016: (Start)
a(n) = 11+42*n+49*n^2+18*n^3.
a(n) = 4*a(n-1)-6*a(n-2)+4*a(n-3)-a(n-4) for n>3.
G.f.: (11+76*x+21*x^2) / (1-x)^4. (End)
E.g.f.: exp(x)*(11 + 109*x + 103*x^2 + 18*x^3). - Stefano Spezia, Aug 07 2024

A274117 a(n) = ((6n-5)!!!+(6n-4)!!!)/(6n-3).

Original entry on oeis.org

1, 12, 1064, 252160, 115315200, 86449126400, 96313245952000, 149342026677043200, 307513455044956160000, 811744577542368870400000, 2672529840751688498380800000, 10735527449319396895332761600000, 51677469466519591978527317032960000, 293652804750537765304678163152896000000
Offset: 1

Author

Keywords

Comments

Sequence is similar to A273889, with a similar proof of divisibility.

Examples

			a(1) = (1+2)/3 = 1;
a(2) = (1*4*7+2*5*8)/9 = 12;
a(3) = (1*4*7*10*13+2*5*8*11*14)/15 = 1064.
		

Crossrefs

Programs

  • Mathematica
    B[n_, k_] := (Product[k (i - 1) + 1, {i, 2 n - 1}] + Product[k (i - 1) + 2, {i, 2 n - 1}])/(2 k (n - 1) + 3); Table[B[n, 3], {n, 14}] (* Michael De Vlieger, Jun 10 2016 *)
  • Python
    triplefac=lambda x:1 if x<2 else x*triplefac(x-3)
    for i in range(1,101):
        print(i,(triplefac(6*i-5)+triplefac(6*i-4))//(6*i-3))

Formula

a(n) = ((6n-5)!!!+(6n-4)!!!)/(6n-3).

A273889 a(n) = ((4n-3)!! + (4n-2)!!) / (4n-1).

Original entry on oeis.org

1, 9, 435, 52017, 11592315, 4152126825, 2182133628675, 1581940549814625, 1512952069890336075, 1845586177840605209625, 2796710279417971723681875, 5153962250373844341910100625, 11351091844757135191108560046875, 29444207228221006416048397134215625, 88848552445321896564985597922269171875
Offset: 1

Keywords

Examples

			a(1) = (1 + 2)/3 = 1;
a(2) = (1*3*5 + 2*4*6)/7 = 9;
a(3) = (1*3*5*7*9 + 2*4*6*8*10)/11 = 435.
		

Crossrefs

Programs

  • Mathematica
    B[n_, k_] := (Product[k (i - 1) + 1, {i, 2 n - 1}] + Product[k (i - 1) + 2, {i, 2 n - 1}])/(2 k (n - 1) + 3); Table[B[n, 2], {n, 15}] (* Michael De Vlieger, Jun 10 2016 *)
    Table[((4n-3)!!+(4n-2)!!)/(4n-1),{n,20}] (* Harvey P. Dale, Mar 08 2018 *)
  • Python
    for n in range(1,101):
        if n == 1:
            a = 1
            b = 2
        else:
            a = a*(4*n-5)*(4*n-3)
            b = b*(4*n-4)*(4*n-2)
        c = (a+b)/(4*n-1)
        print(str(n)+" "+str(c))

A227392 Number of 2-Bottom-Card shuffles required to return a deck of size n to its original order.

Original entry on oeis.org

1, 2, 2, 3, 5, 6, 10, 6, 9, 10, 24, 9, 13, 14, 44, 12, 17, 18, 70, 15, 21, 22, 102, 18, 25, 26, 140, 21, 29, 30, 184, 24, 33, 34, 234, 27, 37, 38, 290, 30, 41, 42, 352, 33, 45, 46, 420, 36, 49, 50
Offset: 1

Author

Hong-Chang Wang, Jul 10 2013

Keywords

Comments

Apply the P card and the B card, the two cards on the bottom of the stack, to do shuffling a deck of cards. The T cards are on the top of cards and the M cards are between the T cards and the P card.
The shuffling steps are like this: (T)(M) P B -> B (T)(M) P -> B (T) P (M).
Let n = T + M +2, (n >= 2). New P = ceiling((n+1)/2).
Count cycles to return original order for the deck of size n.
Order (4k+1)th and (4k+2)th items, k >= 0, can get a Latin square.

Examples

			a(1) = 1
  1
  1
.
a(2) = 2
  1 2
  2 1
  1 2
.
a(3) = 2
  1 2 3
  3 2 1
  1 2 3
.
a(4) = 3
  1 2 3 4
  4 1 3 2
  2 4 3 1
  1 2 3 4
.
a(5) = 5
  1 2 3 4 5
  5 1 4 2 3
  3 5 2 1 4
  4 3 1 5 2
  2 4 5 3 1
  1 2 3 4 5
.
a(6) = 6
  1 2 3 4 5 6
  6 1 2 5 3 4
  4 6 1 3 2 5
  5 4 6 2 1 3
  3 5 4 1 6 2
  2 3 5 6 4 1
  1 2 3 4 5 6
.
a(7) = 10
  1 2 3 4 5 6 7
  7 1 2 6 3 4 5
  5 7 1 4 2 6 3
  3 5 7 6 1 4 2
  2 3 5 4 7 6 1
  1 2 3 6 5 4 7
  7 1 2 4 3 6 5
  5 7 1 6 2 4 3
  3 5 7 4 1 6 2
  2 3 5 6 7 4 1
  1 2 3 4 5 6 7
.
a(8) = 6
  1 2 3 4 5 6 7 8
  8 1 2 3 7 4 5 6
  6 8 1 2 5 3 7 4
  4 6 8 1 7 2 5 3
  3 4 6 8 5 1 7 2
  2 3 4 6 7 8 5 1
  1 2 3 4 5 6 7 8
.
a(9) = 9
  1 2 3 4 5 6 7 8 9
  9 1 2 3 8 4 5 6 7
  7 9 1 2 6 3 8 4 5
  5 7 9 1 4 2 6 3 8
  8 5 7 9 3 1 4 2 6
  6 8 5 7 2 9 3 1 4
  4 6 8 5 1 7 2 9 3
  3 4 6 8 9 5 1 7 2
  2 3 4 6 7 8 9 5 1
  1 2 3 4 5 6 7 8 9
		

Programs

  • C
    int a(int n)
    {
        int c[101];
        int i, step, B, P, m;
        for (i=1 ; i0 ; i--)  { c[i+1] = c[i]; }
        c[1] = B;
        m = (n+2)/2;
        P = c[n];
        if ( n>2 )  { for (i=n-1 ; i>=m ; i--)  c[i+1] = c[i]; }
        c[m] = P;
        step++;
        for (i=1 ; i
    int main()
    {
        int n;
        for (n=1; n<=100; ++n)  printf("%d, ", a(n));
        printf("\n");
        return 0;
    }

Formula

a(4k+1) = 4k+1, k >= 0;
a(4k+2) = 4k+2, k >= 0;
a(4k+3) = 8k+2, k=0,1;
a(4k+3) = a(4k-1) + 6k + 2, k >= 2;
a(4k+4) = 3*(k+1), k >= 0.
From Joerg Arndt, Jul 16 2013: (Start)
G.f.: x*(2*x^9 + 3*x^8 + 3*x^7 - 4*x^6 - 2*x^4 - 3*x^3 - 2*x^2 - 2*x - 1) / ((x-1)*(x+1)*(x^2+1))^3;
a(n) = 3*a(n-4) - 3*a(n-8) + a(n-12). (End)