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.

A082491 a(n) = n! * d(n), where n! = factorial numbers (A000142), d(n) = subfactorial numbers (A000166).

Original entry on oeis.org

1, 0, 2, 12, 216, 5280, 190800, 9344160, 598066560, 48443028480, 4844306476800, 586161043776000, 84407190782745600, 14264815236056985600, 2795903786354347468800, 629078351928420506112000, 161044058093696572354560000, 46541732789077953723039744000
Offset: 0

Views

Author

Emanuele Munarini, Apr 28 2003

Keywords

Comments

a(n) is also the number of pairs of n-permutations p and q such that p(x)<>q(x) for each x in { 1, 2, ..., n }.
Or number of n X n matrices with exactly one 1 and one 2 in each row and column, other entries 0 (cf. A001499). - Vladimir Shevelev, Mar 22 2010
a(n) is approximately equal to (n!)^2/e. - J. M. Bergot, Jun 09 2018

Crossrefs

Programs

  • Maple
    with (combstruct):a:=proc(m) [ZL, {ZL=Set(Cycle(Z, card>=m))}, labeled]; end: ZLL:=a(2):seq(count(ZLL, size=n)*n!, n=0..15); # Zerinvary Lajos, Jun 11 2008
  • Mathematica
    Table[Subfactorial[n]*n!, {n, 0, 15}] (* Zerinvary Lajos, Jul 10 2009 *)
  • Maxima
    A000166[0]:1$
    A000166[n]:=n*A000166[n-1]+(-1)^n$
      makelist(n!*A000166[n], n, 0, 12); /* Emanuele Munarini, Mar 01 2011 */
    
  • PARI
    d(n)=if(n<1, n==0, n*d(n-1)+(-1)^n);
    a(n)=d(n)*n!;
    vector(33,n,a(n-1))
    /* Joerg Arndt, May 28 2012 */
    
  • PARI
    {a(n) = if( n<2, n==0, n! * round(n! / exp(1)))}; /* Michael Somos, Jun 24 2018 */
    
  • Python
    A082491_list, m, x = [], 1, 1
    for n in range(10*2):
        x, m = x*n**2 + m, -(n+1)*m
        A082491_list.append(x) # Chai Wah Wu, Nov 03 2014
    
  • Scala
    val A082491_pairs: LazyList[BigInt && BigInt] =
      (BigInt(0), BigInt(1)) #::
      (BigInt(1), BigInt(0)) #::
      lift2 {
        case ((n, z), (_, y)) =>
          (n+2, (n+2)*(n+1)*((n+1)*z+y))
      } (A082491_pairs, A082491_pairs.tail)
    val A082491: LazyList[BigInt] =
      lift1(_._2)(A082491_pairs)
    /** Luc Duponcheel, Jan 25 2020 */

Formula

a(n) = n! * d(n) where d(n) = A000166(n).
a(n) = Sum_{k=0..n} binomial(n, k)^2 * (-1)^k * (n - k)!^2 * k!.
a(n+2) = (n+2)*(n+1) * ( a(n+1) + (n+1)*a(n) ).
a(n) ~ 2*Pi*n^(2*n+1)*exp(-2*n-1). - Ilya Gutkovskiy, Dec 04 2016