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-10 of 13 results. Next

A002467 The game of Mousetrap with n cards (given n letters and n envelopes, how many ways are there to fill the envelopes so that at least one letter goes into its right envelope?).

Original entry on oeis.org

0, 1, 1, 4, 15, 76, 455, 3186, 25487, 229384, 2293839, 25232230, 302786759, 3936227868, 55107190151, 826607852266, 13225725636255, 224837335816336, 4047072044694047, 76894368849186894, 1537887376983737879, 32295634916658495460, 710503968166486900119
Offset: 0

Views

Author

Keywords

Comments

a(n) is the number of permutations in the symmetric group S_n that have a fixed point, i.e., they are not derangements (A000166). - Ahmed Fares (ahmedfares(AT)my-deja.com), May 08 2001
a(n+1)=p(n+1) where p(x) is the unique degree-n polynomial such that p(k)=k! for k=0,1,...,n. - Michael Somos, Oct 07 2003
The termwise sum of this sequence and A000166 gives the factorial numbers. - D. G. Rogers, Aug 26 2006, Jan 06 2008
a(n) is the number of deco polyominoes of height n and having in the last column an odd number of cells. A deco polyomino is a directed column-convex polyomino in which the height, measured along the diagonal, is attained only in the last column. Example: a(2)=1 because the horizontal domino is the only deco polyomino of height 2 having an odd number of cells in the last column. - Emeric Deutsch, May 08 2008
Starting (1, 4, 15, 76, 455, ...) = eigensequence of triangle A127899 (unsigned). - Gary W. Adamson, Dec 29 2008
(n-1) | a(n), hence a(n) is never prime. - Jonathan Vos Post, Mar 25 2009
a(n) is the number of permutations of [n] that have at least one fixed point = number of positive terms in n-th row of the triangle in A170942, n > 0. - Reinhard Zumkeller, Mar 29 2012
Numerator of partial sum of alternating harmonic series, provided that the denominator is n!. - Richard Locke Peterson, May 11 2020
a(n) is the number of terms in the polynomial expansion of the determinant of a n X n matrix that contains at least one diagonal element. - Adam Wang, May 28 2025

Examples

			G.f. = x + x^2 + 4*x^3 + 15*x^4 + 76*x^5 + 455*x^6 + 3186*x^7 + 25487*x^8 + ...
		

References

  • R. K. Guy, Unsolved Problems Number Theory, E37.
  • R. K. Guy and R. J. Nowakowski, "Mousetrap," in D. Miklos, V. T. Sos and T. Szonyi, eds., Combinatorics, Paul Erdős is Eighty. Bolyai Society Math. Studies, Vol. 1, pp. 193-206, 1993.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Row sums of A068106.
Column k=1 of A293211.
Column k=0 of A299789, A306234, and of A324362.

Programs

  • Maple
    a := proc(n) -add((-1)^i*binomial(n, i)*(n-i)!, i=1..n) end;
    a := n->-n!*add((-1)^k/k!, k=1..n): seq(a(n), n=0..20); # Zerinvary Lajos, May 25 2007
    a := n -> simplify(GAMMA(n+1) - GAMMA(n+1, -1)*exp(-1)):
    seq(a(n), n=0..20); # Peter Luschny, Feb 28 2017
  • Mathematica
    Denominator[k=1; NestList[1+1/(k++ #1)&,1,12]] (* Wouter Meeussen, Mar 24 2007 *)
    a[ n_] := If[ n < 0, 0, n! - Subfactorial[n]] (* Michael Somos, Jan 25 2014 *)
    a[ n_] := If[ n < 1, 0, n! - Round[ n! / E]] (* Michael Somos, Jan 25 2014 *)
    a[ n_] := If[ n < 0, 0, n! - (-1)^n HypergeometricPFQ[ {- n, 1}, {}, 1]](* Michael Somos, Jan 25 2014 *)
    a[ n_] := If[ n < 0, 0, n! SeriesCoefficient[ (1 - Exp[ -x] ) / (1 - x), {x, 0, n}]] (* Michael Somos, Jan 25 2014 *)
    RecurrenceTable[{a[n] == (n - 1) ( a[n - 1] + a[n - 2]), a[0] == 0, a[1] == 1}, a[n], {n, 20}] (* Ray Chandler, Jul 30 2015 *)
  • PARI
    {a(n) = if( n<1, 0, n * a(n-1) - (-1)^n)} /* Michael Somos, Mar 24 2003 */
    
  • PARI
    {a(n) = if( n<0, 0, n! * polcoeff( (1 - exp( -x + x * O(x^n))) / (1 - x), n))} /* Michael Somos, Mar 24 2003 */
    
  • PARI
    a(n) = if(n<1,0,subst(polinterpolate(vector(n,k,(k-1)!)),x,n+1))
    
  • PARI
    A002467(n) = if(n<1, 0, n*A002467(n-1)-(-1)^n); \\ Joerg Arndt, Apr 22 2013

Formula

a(n) = n! - A000166(n) = A000142(n) - A000166(n).
E.g.f.: (1 - exp(-x)) / (1 - x). - Michael Somos, Aug 11 1999
a(n) = (n-1)*(a(n-1) + a(n-2)), n > 1; a(1) = 1. - Michael Somos, Aug 11 1999
a(n) = n*a(n-1) - (-1)^n. - Michael Somos, Aug 11 1999
a(0) = 0, a(n) = floor(n!(e-1)/e + 1/2) for n > 0. - Michael Somos, Aug 11 1999
a(n) = - n! * Sum_{i=1..n} (-1)^i/i!. Limit_{n->infinity} a(n)/n! = 1 - 1/e. - Gerald McGarvey, Jun 08 2004
Inverse binomial transform of A002627. - Ross La Haye, Sep 21 2004
a(n) = (n-1)*(a(n-1) + a(n-2)), n > 1. - Gary Detlefs, Apr 11 2010
a(n) = n! - floor((n!+1)/e), n > 0. - Gary Detlefs, Apr 11 2010
For n > 0, a(n) = {(1-1/exp(1))*n!}, where {x} is the nearest integer. - Simon Plouffe, conjectured March 1993, added Feb 17 2011
0 = a(n) * (a(n+1) + a(n+2) - a(n+3)) + a(n+1) * (a(n+1) + 2*a(n+2) - a(n+3)) + a(n+2) * (a(n+2)) if n >= 0. - Michael Somos, Jan 25 2014
a(n) = Gamma(n+1) - Gamma(n+1, -1)*exp(-1). - Peter Luschny, Feb 28 2017
a(n) = Sum_{k=0..n-1} A047920(n-1,k). - Alois P. Heinz, Sep 01 2021

A132961 Total number of all distinct cycle sizes in all permutations of [n].

Original entry on oeis.org

1, 2, 9, 38, 215, 1384, 10409, 86946, 825075, 8541998, 97590779, 1205343952, 16148472977, 231416203212, 3560209750005, 58104163643054, 1008693571819919, 18477578835352366, 357476371577422955, 7258865626801695048, 154893910336866444009, 3454112338490001478772
Offset: 1

Views

Author

Vladeta Jovovic, Sep 06 2007

Keywords

Crossrefs

Programs

  • Maple
    with(combinat):
    b:= proc(n, i) option remember; `if`(n=0, [1, 0], `if`(i<1, 0,
          add(multinomial(n, n-i*j, i$j)/j!*(i-1)!^j*(p-> p+
          [0, p[1]*`if`(j>0, 1, 0)])(b(n-i*j, i-1)), j=0..n/i)))
        end:
    a:= n-> b(n$2)[2]:
    seq(a(n), n=1..30);  # Alois P. Heinz, Oct 21 2015
  • Mathematica
    Rest[ Range[0, 22]! CoefficientList[ Series[1/(1 - x) Sum[1 - Exp[ -x^k/k], {k, 25}], {x, 0, 22}], x]] (* Robert G. Wilson v, Sep 13 2007 *)

Formula

E.g.f.: 1/(1-x)*Sum_{k>0} (1-exp(-x^k/k)). Exponential convolution of A132960(n) and n!: a(n) = n!*Sum_{k=1..n} A132960(k)/k!.

Extensions

More terms from Robert G. Wilson v, Sep 13 2007

A027616 Number of permutations of n elements containing a 2-cycle.

Original entry on oeis.org

0, 0, 1, 3, 9, 45, 285, 1995, 15855, 142695, 1427895, 15706845, 188471745, 2450132685, 34301992725, 514529890875, 8232476226975, 139952095858575, 2519137759913775, 47863617438361725, 957272348112505425, 20102719310362613925, 442259824841726816925, 10171975971359716789275
Offset: 0

Views

Author

Joe Keane (jgk(AT)jgk.org)

Keywords

Crossrefs

Column k=2 of A293211.

Programs

  • Magma
    A027616:= func< n | Factorial(n)*(1- (&+[(-1/2)^j/Factorial(j): j in [0..Floor(n/2)]]) ) >;
    [A027616(n): n in [0..30]]; // G. C. Greubel, Aug 05 2022
    
  • Maple
    S:= series((1-exp(-x^2/2))/(1-x), x, 101):
    seq(coeff(S,x,j)*j!,j=0..100); # Robert Israel, May 12 2016
  • Mathematica
    nn=30; Table[n!,{n,0,nn}]-Range[0,nn]!CoefficientList[Series[Exp[-x^2/2]/(1-x),{x,0,nn}],x]  (* Geoffrey Critzer, Oct 20 2012 *)
  • PARI
    a(n) = n! * (1 - sum(k=0,floor(n/2), (-1)^k / (2^k * k!) ) );
    /* Joerg Arndt, Oct 20 2012 */
    
  • PARI
    N=33; x='x+O('x^N);
    v=Vec( 'a0 + serlaplace( (1-exp(-x^2/2))/(1-x) ) );
    v[1]-='a0;  v
    /* Joerg Arndt, Oct 20 2012 */
    
  • SageMath
    def A027616(n): return factorial(n)*(1-sum((-1/2)^k/factorial(k) for k in (0..(n//2))))
    [A027616(n) for n in (0..30)] # G. C. Greubel, Aug 05 2022

Formula

E.g.f.: (1 - exp(-x^2/2)) / (1-x).
a(n) = n! * ( 1 - Sum_{k=0..floor(n/2)} (-1)^k / (2^k * k!) ).
a(n) + A000266(n) = n!. - Yuval Dekel (dekelyuval(AT)hotmail.com), Nov 09 2003
Limit_{n -> oo} a(n)/n! = 1 - e^(-1/2) = 1 - A092605. - Michel Marcus, Aug 08 2013

Extensions

Added more terms, Geoffrey Critzer, Oct 20 2012

A052145 a(n) = (2n-1)*(2n-1)!/n.

Original entry on oeis.org

1, 9, 200, 8820, 653184, 73180800, 11564467200, 2451889440000, 671854030848000, 231125690776780800, 97537253236899840000, 49549698749529538560000, 29829250083328819200000000, 20999962511521107738624000000, 17094073187896757112117657600000
Offset: 1

Views

Author

N. J. A. Sloane, Jan 23 2000

Keywords

Comments

This is the number of permutations of 2n letters having a cycle of length n. - Marko Riedel, Apr 21 2015

Examples

			For n=2, there are 9 permutations of [4] = { 1, 2, 3, 4 } which have a cycle of length 2: each of the 4*3/2 = 6 transpositions, plus the 3 different possible products of two transpositions. - _M. F. Hasler_, Apr 21 2015
		

References

  • R. P. Stanley, Enumerative Combinatorics, Cambridge, Vol. 2, 1999; see Problem 7.68(d).

Crossrefs

Programs

Formula

a(n) = 2*m*m!/(m+1) where m=2n-1.
a(n) = A126074(2n,n). - Alois P. Heinz, Apr 21 2017
a(n) = A293211(2n,n). - Alois P. Heinz, Oct 11 2017

A122974 Triangle T(n,k), the number of permutations on n elements that have no cycles of length k.

Original entry on oeis.org

0, 1, 1, 2, 3, 4, 9, 15, 16, 18, 44, 75, 80, 90, 96, 265, 435, 520, 540, 576, 600, 1854, 3045, 3640, 3780, 4032, 4200, 4320, 14833, 24465, 29120, 31500, 32256, 33600, 34560, 35280, 133496, 220185, 259840, 283500, 290304, 302400, 311040, 317520, 322560
Offset: 1

Views

Author

Dennis P. Walsh, Oct 27 2006

Keywords

Comments

Read as sequence, a(n) is the number of permutations on j elements with no cycles of length i where j=round((2*n)^.5) and i=n-C(j,2).
T(n,k) generalizes several sequences already in the On-Line Encyclopedia, such as A000166, the number of permutations on n elements with no fixed points and A000266, the number of permutations on n elements with no transpositions (i.e., no 2-cycles). See the cross references for further examples.

Examples

			T(3,2)=3 since there are exactly 3 permutations of 1,2,3 that have no cycles of length 2, namely, (1)(2)(3),(1 2 3) and (2 1 3).
Triangle T(n,k) begins:
      0;
      1,     1;
      2,     3,     4;
      9,    15,    16,    18;
     44,    75,    80,    90,    96;
    265,   435,   520,   540,   576,   600;
   1854,  3045,  3640,  3780,  4032,  4200,  4320;
  14833, 24465, 29120, 31500, 32256, 33600, 34560, 35280;
  ...
		

Crossrefs

Cf. T(n, 1)=A000166 for n=>1 T(n, 2)=A000266 for n=>2 T(n, 3)=A000090 for n=>3 T(n, 4)=A000138 for n=>4 T(n, 5)=A060725 for n=>5 T(n, 6)=A060726 for n=>6 T(n, 7)=A060727 for n=>7.
T(n,n) gives A094304(n+1).

Programs

  • Maple
    seq((round((2*n)^.5))!*sum((-1/(n-binomial(round((2*n)^.5),2)))^r/r!,r=0..floor(round((2*n)^.5)/(n-binomial(round((2*n)^.5),2)))),n=1..66);
    # second Maple program:
    T:= proc(n, k) option remember; `if`(n=0, 1, add(`if`(j=k, 0,
          T(n-j, k)*binomial(n-1, j-1)*(j-1)!), j=1..n))
        end:
    seq(seq(T(n, k), k=1..n), n=1..12);  # Alois P. Heinz, Nov 24 2019
  • Mathematica
    T[n_, k_] := T[n, k] = If[n==0, 1, Sum[If[j==k, 0, T[n - j, k] Binomial[n - 1, j - 1] (j - 1)!], {j, 1, n}]];
    Table[Table[T[n, k], {k, 1, n}], {n, 1, 12}] // Flatten (* Jean-François Alcover, Dec 08 2019, after Alois P. Heinz *)

Formula

T(n,k)=n!*sum r=0..floor(n/k)((-1/k)^r/r!) E.G.F: exp(-x^k/k)/(1-x) a(n)=(round((2*n)^.5))!*sum((-1/(n-binomial(round((2*n)^.5),2)))^r/r!,r=0..floor(round((2*n)^.5)/(n-binomial(round((2*n)^.5),2)))).
T(n,k) = n! - A293211(n,k). - Alois P. Heinz, Nov 24 2019

A027617 Number of permutations of n elements containing a 3-cycle.

Original entry on oeis.org

0, 0, 0, 2, 8, 40, 200, 1400, 11200, 103040, 1030400, 11334400, 135766400, 1764963200, 24709484800, 370687116800, 5930993868800, 100826895769600, 1814871926067200, 34482566595276800, 689651331905536000, 14482682605174784000, 318619017313845248000
Offset: 0

Views

Author

Joe Keane (jgk(AT)jgk.org)

Keywords

Comments

a(n)/n! is asymptotic to 1-e^(-1/3) = 1 - A092615. - Michel Marcus, Aug 08 2013

Crossrefs

Column k=3 of A293211.

Programs

  • Mathematica
    nn=20;Range[0,nn]!CoefficientList[Series[1/(1-x)-Exp[-x^3/3]/(1-x), {x,0,nn}],x]  (* Geoffrey Critzer, Jan 23 2013 *)
  • PARI
    a(n) = n! * (1 - sum(k=0, floor(n/3), (-1)^k/(k!*3^k) ) ); \\ Stéphane Rézel, Dec 11 2019

Formula

a(n) = n! * ( 1 - Sum_{k=0..floor(n/3)} (-1)^k / (3^k * k!) ).
E.g.f.: 1/(1-x) - exp(-x^3/3)/(1-x). - Geoffrey Critzer, Jan 23 2013
Recurrence: a(n) = n*a(n-1) - (n-2)*(n-1)*a(n-3) + (n-3)*(n-2)*(n-1)*a(n-4). - Vaclav Kotesovec, Aug 13 2013
Conjectures from Stéphane Rézel, Dec 11 2019: (Start)
Recurrence: a(n) = n*a(n-1), for n > 3 and n !== 0 (mod 3);
for k > 1, a(3*k) = a(3*k-1)*S(k)/S(k-1) where S(k) = 3*k*S(k-1) - (-1)^k with S(1) = 1.
(End)

Extensions

More terms from Geoffrey Critzer, Jan 23 2013

A029571 Number of permutations of an n-set containing a 4-cycle.

Original entry on oeis.org

0, 0, 0, 0, 6, 30, 180, 1260, 8820, 79380, 793800, 8731800, 106029000, 1378377000, 19297278000, 289459170000, 4627941318000, 78675002406000, 1416150043308000, 26906850822852000, 538156815464268000
Offset: 0

Views

Author

Keywords

Crossrefs

Column k=4 of A293211.

Programs

  • Maple
    L:= [seq( 1 - add((-1)^k/(k!*4^k),k=0..m),m=0..10)]:
    seq(seq((4*m+j)!*L[m+1],j=0..3),m=0..10); # Robert Israel, Dec 07 2016
  • Mathematica
    a[n_] := n! (1 - Sum[(-1)^k/(k! 4^k), {k, 0, Floor[n/4]}]);
    Table[a[n], {n, 0, 20}] (* Jean-François Alcover, Mar 19 2019 *)
  • PARI
    a(n)=n! * (1 - sum(k=0,floor(n/4), (-1)^k/(k!*4^k) ) ); \\ Joerg Arndt, Aug 08 2013

Formula

a(n) = n! * (1 - sum(k=0..floor(n/4), (-1)^k/(k!*4^k) ) ).
a(n)/n! is asymptotic to 1-e^(-1/4) = 1 - A092616.
a(n) = n! (1 - Gamma(floor(n/4)+1,-1/4)*exp(1/4)/(floor(n/4))!). - Robert Israel, Dec 07 2016
E.g.f.: (1-exp(-x^4/4))/(1-x). - Alois P. Heinz, Oct 11 2017

A029572 Number of permutations of an n-set containing a 5-cycle.

Original entry on oeis.org

0, 0, 0, 0, 0, 24, 144, 1008, 8064, 72576, 653184, 7185024, 86220288, 1120863744, 15692092416, 237124952064, 3793999233024, 64497986961408, 1160963765305344, 22058311540801536, 441004037348818944, 9261084784325197824, 203743865255154352128, 4686108900868550098944
Offset: 0

Views

Author

Keywords

Crossrefs

Column k=5 of A293211.

Programs

  • Mathematica
    nn = 20; a = Log[1/(1 - x)] - x^5/5; Range[0, nn]! CoefficientList[Series[1/(1 - x) - Exp[a], {x, 0, nn}],x] (* Geoffrey Critzer, Jun 01 2013 *)
  • PARI
    my(x='x+O('x^66)); concat([0,0,0,0,0], Vec(serlaplace((1-exp(-x^5/5))/(1-x)))) \\ Joerg Arndt, Jun 01 2013

Formula

a(n) = n!*(1 - Sum_{k=0..floor(n/5)} (-1)^k/(k!*5^k)).
a(n)/n! is asymptotic to 1-e^(-1/5) = 1 - A092618.
E.g.f.: (1-exp(-x^5/5))/(1-x) - Geoffrey Critzer, Jun 01 2013

A029573 Number of permutations of an n-set containing a 6-cycle.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 120, 840, 6720, 60480, 604800, 6652800, 73180800, 951350400, 13318905600, 199783584000, 3196537344000, 54341134848000, 983080530432000, 18678530078208000, 373570601564160000, 7844982632847360000, 172589617922641920000, 3969561212220764160000
Offset: 0

Views

Author

Keywords

Crossrefs

Column k=6 of A293211.

Programs

  • PARI
    a(n) = n! * (1 - sum(k=0, floor(n/6), (-1)^k/(k!*6^k) ) ); \\ Michel Marcus, Aug 08 2013

Formula

a(n) = n! * (1 - sum_{k=0..floor(n/6)} (-1)^k/(k!*6^k)).
a(n)/n! is asymptotic to 1-e^(-1/6) = 1 - A092727.
E.g.f.: (1-exp(-x^6/6))/(1-x). - Alois P. Heinz, Oct 11 2017

A029574 Number of permutations of an n-set containing a 7-cycle.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 720, 5760, 51840, 518400, 5702400, 68428800, 889574400, 11564467200, 173467008000, 2775472128000, 47183026176000, 849294471168000, 16136594952192000, 322731899043840000, 6802195410616320000, 149648299033559040000, 3441910877771857920000
Offset: 0

Views

Author

Keywords

Crossrefs

Column k=7 of A293211.

Programs

  • PARI
    a(n) = n! * (1 - sum(k=0, floor(n/7), (-1)^k/(k!*7^k) ) ); \\ Michel Marcus, Aug 08 2013

Formula

a(n) = n! * (1 - sum_{k=0..floor(n/7)} (-1)^k/(k!*7^k)).
a(n)/n! is asymptotic to 1-e^(-1/7) = 1 - A092750.
E.g.f.: (1-exp(-x^7/7))/(1-x). - Alois P. Heinz, Oct 11 2017
Showing 1-10 of 13 results. Next