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.

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

A002468 The game of Mousetrap with n cards: the number of permutations of n cards having at least one hit after 2.

Original entry on oeis.org

0, 0, 1, 3, 13, 65, 397, 2819, 22831, 207605, 2094121, 23205383, 280224451, 3662810249, 51523391965, 776082247979, 12463259986087, 212573743211549, 3837628837381201, 73108996989052175, 1465703611456618891, 30847249002794047793, 679998362512214208901, 15668677914172813691699, 376683592679293811722735
Offset: 1

Views

Author

Keywords

Comments

The subsequence of primes begins: 3, 13, 397, 2819, no more through a(19). - Jonathan Vos Post, Feb 01 2011

References

  • 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

  • Mathematica
    a[n_] := (n-2)*(n-2)!-(n-4)*Subfactorial[n-3]-(n-3)*Subfactorial[n-2]; a[1]=a[2]=0; a[3]=1; Table[a[n], {n, 1, 21}] (* Jean-François Alcover, Dec 12 2014 *)

Formula

a(n) = A001563(n) - A002469(n+2). (corrected by Sean A. Irvine and Joerg Arndt, Feb 10 2014)

Extensions

Added two more terms, Joerg Arndt, Feb 15 2014

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
Showing 1-3 of 3 results.