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.

A112541 a(n) = Sum_{k=0..n} (n-k)! * n^k.

Original entry on oeis.org

1, 2, 8, 48, 400, 4390, 60624, 1013404, 19881728, 447085170, 11319529600, 318298578664, 9834869311488, 331059072378814, 12055438037135360, 472096504892128500, 19781301201305534464, 882991510898240350666, 41828674437875442696192, 2095750482492627217639360
Offset: 0

Views

Author

Roger Cuculière, Dec 17 2005

Keywords

Comments

This sequence appears in the calculation of the expectation of the number of runs of an n-faced die, stopping when a face appears for the second time.

Crossrefs

Cf. A000142.

Programs

  • Magma
    [(&+[Factorial(k)*n^(n-k): k in [0..n]]): n in [0..20]]; // G. C. Greubel, Jan 12 2022
    
  • Maple
    A112541 := proc(n)
        add((n-k)!*n^k,k=0..n) ;
    end proc:
    seq(A112541(n),n=0..13) ; # R. J. Mathar, Dec 16 2015
  • Mathematica
    a[n_]:= Sum[(n-k)!n^k, {k, 0, n}]; Array[a, 17] (* Robert G. Wilson v, Dec 22 2005 *)
  • PARI
    a(n) = my(A = 1, B = 1); for(k=1, n, B *= n; A = (n-k+1)*A + B); A \\ Mikhail Kurkov, Aug 09 2025
  • Sage
    [sum(factorial(k)*n^(n-k) for k in (0..n)) for n in (0..20)] # G. C. Greubel, Jan 12 2022
    

Formula

a(n) = Sum_{k=0..n} k! * n^(n-k). - G. C. Greubel, Jan 12 2022

Extensions

Corrected and extended by Robert G. Wilson v, Dec 22 2005