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-7 of 7 results.

A260783 Erroneous version of A002468.

Original entry on oeis.org

0, 1, 3, 13, 65, 403, 2885, 23515, 214805
Offset: 2

Views

Author

Keywords

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

A002469 The game of Mousetrap with n cards: the number of permutations of n cards in which 2 is the only hit.

Original entry on oeis.org

0, 0, 1, 5, 31, 203, 1501, 12449, 114955, 1171799, 13082617, 158860349, 2085208951, 29427878435, 444413828821, 7151855533913, 122190894996451, 2209057440250799, 42133729714051825, 845553296311189109, 17810791160738752207, 392911423093684031099
Offset: 2

Views

Author

Keywords

Examples

			G.f.: x^4 + 5*x^5 + 31*x^6 + 203*x^7 + 1501*x^8 + 12449*x^9 + 114955*x^10 + ...
		

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

Programs

  • Maple
    A002469:=n->(n-3)*floor(((n-2)!+1)/exp(1)) + (n-4)*floor(((n-3)!+1)/exp(1)): 0, seq(A002469(n), n=3..30); # Wesley Ivan Hurt, Jan 10 2017
  • Mathematica
    Join[{0},Table[(n-3)Floor[((n-2)!+1)/E]+(n-4)Floor[((n-3)!+1)/E], {n,3,30}]] (* Harvey P. Dale, Feb 05 2012 *)
    a[n_] := (n-3)*Subfactorial[n-2]+(n-4)*Subfactorial[n-3]; a[n_ /; n <= 3] = 0; Table[a[n], {n, 2, 23}] (* Jean-François Alcover, Dec 12 2014 *)
  • PARI
    default(realprecision,200);
    e=exp(1);
    A002469(n) = if( n<=3, 0, (n-3)*floor(((n-2)!+1)/e) + (n-4)*floor(((n-3)!+1)/e) );
    /* Joerg Arndt, Apr 22 2013 */

Formula

a(n) = sum of terms in (n-2)-nd row of triangle A159610; equivalent to: a(n) = (n-2)*A000255(n-1) + A000166(n). - Gary W. Adamson, Apr 17 2009
a(n) = (n-3)* A000166(n-2) + (n-4)* A000166(n-3). - Gary Detlefs, Apr 10 2010
a(n) = (n-3)*floor(((n-2)!+1)/e) + (n-4)*floor(((n-3)!+1)/e), for n>2. - Gary Detlefs, Apr 10 2010
G.f.: x - 1 + (1-2*x)/(x*Q(0)), where Q(k) = 1/x - (2*k+1) - (k+1)*(k+2)/Q(k+1); (continued fraction). - Sergei N. Gladkovskii, Apr 25 2013

Extensions

More terms from Harvey P. Dale, Feb 05 2012

A018934 From the game of Mousetrap.

Original entry on oeis.org

0, 0, 0, 2, 8, 42, 256, 1810, 14568, 131642, 1320128, 14551074, 174879880, 2276108362, 31894886208, 478775722802, 7664993150696, 130369025763930, 2347604596782208, 44619881467365442, 892659329531868168, 18750556523491299434, 412601744979927877760, 9491630163800726992722
Offset: 0

Views

Author

Keywords

Comments

Number of permutations p of [n] such that p(k) = k+2 for exactly one k in the range 0 < k < n-1. - Vladeta Jovovic, Nov 30 2007

Crossrefs

Programs

  • Mathematica
    Join[{0,0},With[{nn=30},CoefficientList[Series[(2x Exp[-x])/(1-x)^3, {x,0,nn}],x] Range[0,nn]!]] (* Harvey P. Dale, Nov 16 2013 *)
  • PARI
    C=binomial;
    a(n)=if(n<=2, 0, n! + sum(k=1,n, (-1)^k * ( C(n-1,k)+C(n-2,k-1) )*(n-k)! ) );
    /* Joerg Arndt, Apr 22 2013 */
    
  • Sage
    def A():
        a, b, n  = 1, 1, 1
        yield 0
        while True:
            yield b - a
            n += 1
            a, b = b, (n-2)*a+(n-1)*b
    A018934 = A()
    print([next(A018934) for  in range(24)]) # _Peter Luschny, Jan 30 2017

Formula

From Vladeta Jovovic, Nov 30 2007: (Start)
a(n) = (n-2)*A055790(n-2).
E.g.f.: 2*x*exp(-x)/(1-x)^3. (End)
a(n) = floor((n!+1)/e) - floor(((n-2)!+1)/e), n > 2. - Gary Detlefs, Mar 27 2011
G.f.: (1-x)*x/Q(0) - x, where Q(k) = 1 + x - x*(k+2)/(1 - x*(k+1)/Q(k+1)); (continued fraction). - Sergei N. Gladkovskii, Apr 22 2013
G.f.: G(0)*x - x, where G(k) = 1 - x^2*(k+1)*(k+2)/(x^2*(k+1)*(k+2) - (1-x*(1+2*k))*(1-x*(3+2*k))/G(k+1) ); (continued fraction). - Sergei N. Gladkovskii, Feb 05 2014
For n > 1, a(n) = (n-1)*A000166(n-1) + (n-2)*A000166(n-2). - Kevin Long, Feb 21 2021

Extensions

More terms from Vladeta Jovovic, Nov 30 2007, corrected Jan 25 2008

A018932 The number of permutations of n cards in which 4 will be the next hit after 2.

Original entry on oeis.org

0, 3, 10, 60, 408, 3120, 26640, 252000, 2620800, 29756160, 366508800, 4869849600, 69455232000, 1058593536000, 17174123366400, 295534407168000, 5377157001216000, 103149354147840000, 2080771454361600000
Offset: 4

Views

Author

Keywords

Comments

From the game of Mousetrap.

Crossrefs

Cf. A002468.

Programs

  • GAP
    Concatenation([0,3], List([6..30], n-> (n^2-8*n+17)*Factorial(n-4) )); # G. C. Greubel, Feb 21 2019
  • Magma
    [0,3] cat [(n^2-8*n+17)*Factorial(n-4): n in [6..30]]; // G. C. Greubel, Feb 21 2019
    
  • Maple
    0,3,seq((n^2-8*n+17)*factorial(n-4),n=6..30); # Muniru A Asiru, Feb 22 2019
  • Mathematica
    Join[{0,3}, Table[(n^2-8*n+17)*(n-4)!, {n,6,30}]] (* G. C. Greubel, Feb 21 2019 *)
  • PARI
    for(n=4,30, print1(if(n==4, 0, if(n==5, 3, (n^2-8*n+17)*(n-4)!)), ", ")) \\ G. C. Greubel, Feb 21 2019
    
  • Sage
    [0,3] + [(n^2-8*n+17)*factorial(n-4) for n in (6..30)] # G. C. Greubel, Feb 21 2019
    

Formula

a(n) = (n-2)! - 3*(n-3)! + 2*(n-4)! if n > 5. - R. J. Mathar, Oct 02 2008
E.g.f.: (x*(1020 - 1290*x + 340*x^2 - 15*x^3 + 3*x^4) + 60*(17 - 30*x + 15*x^2 - 2*x^3)*log(1-x))/360. - G. C. Greubel, Feb 21 2019

Extensions

Offset changed to 4, more terms, better definition and link from R. J. Mathar, Oct 02 2008

A018931 The number of permutations of n cards in which 2 is the first card hit and 3 the next hit after 2.

Original entry on oeis.org

0, 1, 2, 12, 72, 480, 3600, 30240, 282240, 2903040, 32659200, 399168000, 5269017600, 74724249600, 1133317785600, 18307441152000, 313841848320000, 5690998849536000, 108840352997376000, 2189611807358976000, 46225138155356160000, 1021818843434188800000
Offset: 3

Views

Author

Keywords

Comments

From the game of Mousetrap.

References

  • Daniel J. Mundfrom, A problem in permutations: the game of "Mousetrap". European J. Combin. 15 (1994), no. 6, 555-560.

Crossrefs

Cf. A002468.

Formula

a(n) = A062119(n-3), n > 4. - R. J. Mathar, Oct 02 2008

Extensions

Offset changed to 3 and more precise definition provided by R. J. Mathar, Oct 02 2008

A018933 From the game of Mousetrap.

Original entry on oeis.org

2, 11, 50, 348, 2712, 23520, 225360, 2368800, 27135360, 336752640, 4503340800, 64585382400, 989138304000, 16115529830400, 278360283801600, 5081622594048000, 97772197146624000, 1977622100213760000
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A002468.

Programs

  • Maple
    c := proc(n,x) local a,i; if n > x+1 then a := (n-2)! ; for i from 3 to x do a := a+(-1)^i*(binomial(x-2,i-2)+binomial(x-3,i-3))*(n-i)! ; od: fi; a ; end: A018933 := proc(n) if n = 5 then 2 ; elif n = 6 then 11 ; else c(n,5) ; fi: end: for n from 5 to 23 do printf("%d,",A018933(n)) ; od: # R. J. Mathar, Oct 02 2008
  • Mathematica
    c[n_, x_] := Module[{a = 0, i}, If[n > x+1, a = (n-2)!; For[i = 3, i <= x, i++, a += (-1)^i (Binomial[x-2, i-2] + Binomial[x-3, i-3]) (n-i)!]]; a];
    b[n_] := If[n == 5, 2, If[n == 6, 11, c[n, 5]]];
    a[n_] := b[n + 5];
    a /@ Range[0, 17] (* Jean-François Alcover, Apr 05 2020, after R. J. Mathar *)

Extensions

This entry was corrupted by a misplaced edit Nov 30 2007; previous (and correct) version restored by N. J. A. Sloane Jan 25 2008
More terms from R. J. Mathar, Oct 02 2008
Showing 1-7 of 7 results.