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 19 results. Next

A056542 a(n) = n*a(n-1) + 1, a(1) = 0.

Original entry on oeis.org

0, 1, 4, 17, 86, 517, 3620, 28961, 260650, 2606501, 28671512, 344058145, 4472755886, 62618582405, 939278736076, 15028459777217, 255483816212690, 4598708691828421, 87375465144740000, 1747509302894800001, 36697695360790800022, 807349297937397600485
Offset: 1

Views

Author

Henry Bottomley, Jun 20 2000

Keywords

Comments

For n >= 2 also operation count to create all permutations of n distinct elements using Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2. Sequence gives number of loop repetitions of the j search loop in step L2. - Hugo Pfoertner, Feb 06 2003
More directly: sum over all permutations of length n-1 of the product of the length of the first increasing run by the value of the first position. The recurrence follows from this definition. - Olivier Gérard, Jul 07 2011
This sequence shares divisibility properties with A000522; each of the primes in A072456 divide only a finite number of terms of this sequence. - T. D. Noe, Jul 07 2005
This sequence also represents the number of subdeterminant evaluations when calculation a determinant by Laplace recursive method. - Reinhard Muehlfeld, Sep 14 2010
Also, a(n) equals the number of non-isomorphic directed graphs of n+1 vertices with 1 component, where each vertex has exactly one outgoing edge, excluding loops and cycle graphs. - Stephen Dunn, Nov 30 2019

Examples

			a(4) = 4*a(3) + 1 = 4*4 + 1 = 17.
Permutations of order 3 .. Length of first run * First position
123..3*1
132..2*1
213..1*2
231..2*2
312..1*3
321..1*3
a(4) = 3+2+2+4+3+3 = 17. - _Olivier Gérard_, Jul 07 2011
		

References

  • D. E. Knuth: The Art of Computer Programming, Volume 4, Combinatorial Algorithms, Volume 4A, Enumeration and Backtracking. Pre-fascicle 2B, A draft of section 7.2.1.2: Generating all permutations. Available online; see link.

Crossrefs

Cf. A079751 (same recursion formula, but starting from a(3)=0), A038155, A038156, A080047, A080048, A080049.
Equals the row sums of A162995 triangle (n>=2). - Johannes W. Meijer, Jul 21 2009
Cf. A070213 (indices of primes).

Programs

  • Haskell
    a056542 n = a056542_list !! (n-1)
    a056542_list = 0 : map (+ 1) (zipWith (*) [2..] a056542_list)
    -- Reinhard Zumkeller, Mar 24 2013
    
  • Magma
    [n le 2 select n-1 else n*Self(n-1)+1: n in [1..20]]; // Bruno Berselli, Dec 13 2013
  • Mathematica
    tmp=0; Join[{tmp}, Table[tmp=n*tmp+1, {n, 2, 100}]] (* T. D. Noe, Jul 12 2005 *)
    FoldList[ #1*#2 + 1 &, 0, Range[2, 21]] (* Robert G. Wilson v, Oct 11 2005 *)

Formula

a(n) = floor((e-2)*n!).
a(n) = A002627(n) - n!.
a(n) = A000522(n) - 2*n!.
a(n) = n! - A056543(n).
a(n) = (n-1)*(a(n-1) + a(n-2)) + 2, n > 2. - Gary Detlefs, Jun 22 2010
1/(e - 2) = 2! - 2!/(1*4) - 3!/(4*17) - 4!/(17*86) - 5!/(86*517) - ... (see A002627 and A185108). - Peter Bala, Oct 09 2013
E.g.f.: (exp(x) - 1 - x) / (1 - x). - Ilya Gutkovskiy, Jun 26 2022

Extensions

More terms from James Sellers, Jul 04 2000

A038155 a(n) = (n!/2) * Sum_{k=0..n-2} 1/k!.

Original entry on oeis.org

0, 0, 1, 6, 30, 160, 975, 6846, 54796, 493200, 4932045, 54252550, 651030666, 8463398736, 118487582395, 1777313736030, 28437019776600, 483429336202336, 8701728051642201, 165332832981201990, 3306656659624039990, 69439789852104840000
Offset: 0

Views

Author

Keywords

Comments

For n>=2, a(n) gives the operation count to create all permutations of n distinct elements using Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2. Sequence gives the number of comparisons required to find the first interchangeable element in step L3 (see answer to exercise 5). - Hugo Pfoertner, Jan 27 2003
a(n) mod 5 = A011658(n+1). - G. C. Greubel, Apr 13 2016
a(450) has 1001 decimal digits. - Michael De Vlieger, Apr 13 2016
Also the number of (undirected) paths in the complete graph K_n. - Eric W. Weisstein, Jun 04 2017

References

  • D. E. Knuth: The Art of Computer Programming, Volume 4, Combinatorial Algorithms, Volume 4A, Enumeration and Backtracking. Pre-fascicle 2B, A draft of section 7.2.1.2: Generating all permutations. Available online; see link.

Crossrefs

Programs

  • Maple
    A038155:=n->(n!/2)*add(1/k!, k=0..n-2): seq(A038155(n), n=0..30); # Wesley Ivan Hurt, Apr 16 2016
  • Mathematica
    RecurrenceTable[{a[0] == 0, a[n] == Sum[a[n - 1] + k, {k, 0, n - 1}]}, a, {n, 21}] (* Ilya Gutkovskiy, Apr 13 2016 *)
    Table[(n!/2) Sum[1/k!, {k, 0, n - 2}], {n, 0, 21}] (* Michael De Vlieger, Apr 13 2016 *)
    Table[1/2 E (n - 1) n Gamma[n - 1, 1], {n, 0, 20}] (* Eric W. Weisstein, Jun 04 2017 *)
    Table[If[n == 0, 0, Floor[n! E - n - 1]/2], {n, 0, 20}] (* Eric W. Weisstein, Jun 04 2017 *)

Formula

a(n) = 1/2*floor(n!*exp(1)-n-1), n>0. - Vladeta Jovovic, Aug 18 2002
E.g.f.: x^2/2*exp(x)/(1-x). - Vladeta Jovovic, Aug 25 2002
a(n) = Sum_{k=0..n-1} a(n-1) + k, a(0)=0. - Ilya Gutkovskiy, Apr 13 2016
a(n) = A038154(n)/2. - Alois P. Heinz, Jan 26 2017

A079884 Number of comparisons required to create all permutations of n distinct elements using the "streamlined" version of Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2.

Original entry on oeis.org

11, 54, 285, 1731, 12145, 97196, 874809, 8748145, 96229661, 1154756010, 15011828221, 210165595199, 3152483928105, 50439742849816, 857475628447025, 15434561312046621, 293256664928885989, 5865133298577719990, 123167799270132120021, 2709691583942906640715, 62322906430686852736721
Offset: 3

Views

Author

Hugo Pfoertner, Jan 12 2003

Keywords

Comments

The method generates all permutations in lexicographic order. It is described in the answer to Exercise 1, Section 7.2.1.2 of Knuth's The Art of Computer Programming Vol. 4. The description is based on the Algol procedure NEXTPERM by J.P.N.Phillips. The operation counts were determined with a FORTRAN subroutine LPG. To create all permutations of n distinct elements the number of comparisons between the array elements approaches 2.410756*n! for large n (e.g. n>8).

Examples

			The "streamlined" permutation algorithm L' needs fewer comparisons a(n) than the original Algorithm L, for which the number of required comparisons between the elements to be permuted is given by A038156(n) for step L2 and A038155(n) for step L3. A038156(3)+A038155(3)=9+6=15 > a(3)=11 A038156(4)+A038155(4)=40+30=70 > a(4)=54 A038156(10)+A038155(10)=6235300+4932045=11167345 > a(10)=8748145.
		

References

  • D. E. Knuth: The Art of Computer Programming, Volume 4, Combinatorial Algorithms, Volume 4A, Enumeration and Backtracking. Pre-fascicle 2B, A draft of section 7.2.1.2: Generating all permutations.
  • J. P. N. Phillips: "Algorithm 28, PERMUTATIONS OF THE ELEMENTS OF A VECTOR IN LEXICOGRAPHIC ORDER" The Computer Journal, Volume 10, Issue 3: November 1967. (Algorithms supplement), page 311. See link.

Crossrefs

Partial counts given in A079750, A079753.
Number of index tests: A079885.

Programs

  • Fortran
    Program available at Pfoertner link
    
  • PARI
    a079884(nmax) = {my(a=vector(nmax)); a[3]=11; for(k=4, nmax, a[k]=k*a[k-1]+k*(k+1)/2); a[3..nmax]} \\ Hugo Pfoertner, Jun 05 2024

Formula

a(3) = 11; a(n) = n*a(n-1) + n*(n+1)/2.
a(n) = 2*n! - 1 + A079750(n) + A079753(n).
For n>=3, a(n)=floor(c*n!-(n-3)/2) where c = lim_{n->oo} a(n)/n! = 2.4107560760219... - Benoit Cloitre; c=3*e/2-5/3 - Guido Dhondt (dhondt(AT)t-online.de), Jan 20 2003

A119741 A008279, with the first and last of each row removed.

Original entry on oeis.org

2, 3, 6, 4, 12, 24, 5, 20, 60, 120, 6, 30, 120, 360, 720, 7, 42, 210, 840, 2520, 5040, 8, 56, 336, 1680, 6720, 20160, 40320, 9, 72, 504, 3024, 15120, 60480, 181440, 362880, 10, 90, 720, 5040, 30240, 151200, 604800, 1814400, 3628800, 11, 110, 990, 7920, 55440, 332640, 1663200, 6652800, 19958400, 39916800
Offset: 2

Views

Author

Lekraj Beedassy, Jul 29 2006

Keywords

Comments

Triangle read by rows: T(n,k) (n>=2, k=1..n-1) is the number of topologies t on n points having exactly k+2 open sets such that t contains exactly one open set of size m for each m in {0,1,2,...,s,n} where s is the size of the largest proper open set in t. - N. J. A. Sloane, Jan 29 2016 [clarified by Geoffrey Critzer, Feb 19 2017]

Examples

			Triangle begins:
   2;
   3,  6;
   4, 12,  24;
   5, 20,  60,  120;
   6, 30, 120,  360,   720;
   7, 42, 210,  840,  2520,   5040;
   8, 56, 336, 1680,  6720,  20160,  40320;
   9, 72, 504, 3024, 15120,  60480, 181440,  362880;
  10, 90, 720, 5040, 30240, 151200, 604800, 1814400, 3628800;
  ...
		

Crossrefs

Row sums give A038156.
Triangles in this series: A268216, A268217, A268221, A268222, A268223.

Programs

  • Maple
    T:= (n, k)-> n!/(n-k)!:
    seq(seq(T(n,k), k=1..n-1), n=2..11);  # Alois P. Heinz, Aug 22 2025
  • Mathematica
    Table[FactorialPower[n, k], {n, 2, 11}, {k, 1, n-1}] // Flatten (* Jean-François Alcover, Feb 21 2020 *)

Formula

a(n) = (A003057(n))!/(A004736(n))! = (A002260(n))!*(A014410(n)).
T(n,k) = A173333(n+1,n-k+1), 1<=k<=n. - Reinhard Zumkeller, Feb 19 2010

Extensions

Edited by Don Reble, Aug 01 2006

A080047 Operation count to create all permutations of n distinct elements using Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2. Sequence gives number of times l has to be repeatedly decreased in step L3.

Original entry on oeis.org

0, 1, 7, 41, 256, 1807, 14477, 130321, 1303246, 14335751, 172029067, 2236377937, 31309291196, 469639368031, 7514229888601, 127741908106337, 2299354345914202, 43687732572369991, 873754651447399991
Offset: 2

Views

Author

Hugo Pfoertner, Jan 25 2003

Keywords

References

  • D. E. Knuth: The Art of Computer Programming, Volume 4, Combinatorial Algorithms, Volume 4A, Enumeration and Backtracking. Pre-fascicle 2B, A draft of section 7.2.1.2: Generating all permutations. Available online; see link.

Crossrefs

Programs

  • Mathematica
    Transpose[NestList[{First[#]+1,(First[#]+1)Last[#]+(First[#](First[#]-1))/2}&, {2,0},20]][[2]] (* Harvey P. Dale, Feb 27 2012 *)
    Rest[Rest[CoefficientList[Series[(2-Exp[x]*(x^2-2*x+2))/(2*(x-1)),{x,0,20}],x]*Range[0,20]!]] (* Vaclav Kotesovec, Oct 21 2012 *)

Formula

a(2)=0, a(n) = n*a(n-1)+(n-1)*(n-2)/2 for n>=3 c = limit n--> infinity a(n)/n! = 0.35914091422952261768 = e/2-1, a(n) = floor [c*n! - (n-1)/2] for n>=2
E.g.f.: (2-exp(x)*(x^2-2*x+2))/(2*(x-1)). - Vaclav Kotesovec, Oct 21 2012

A080048 Operation count to create all permutations of n distinct elements using Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2. Sequence gives number of loop repetitions in reversal step.

Original entry on oeis.org

1, 7, 34, 182, 1107, 7773, 62212, 559948, 5599525, 61594835, 739138086, 9608795202, 134523132919, 2017846993897, 32285551902472, 548854382342168, 9879378882159177, 187708198761024543, 3754163975220491050
Offset: 2

Views

Author

Hugo Pfoertner, Jan 24 2003

Keywords

References

  • D. E. Knuth: The Art of Computer Programming, Volume 4, Combinatorial Algorithms, Volume 4A, Enumeration and Backtracking. Pre-fascicle 2B, A draft of section 7.2.1.2: Generating all permutations. Available online; see link.

Crossrefs

Programs

  • Fortran
    ! Program available at link.

Formula

a(2)=1, a(n)=n*a(n-1) + (n-1)*floor[(n+1)/2] for n>=3.
c = limit n --> infinity a(n)/n! = 1.54308063481524377826 = (e+1/e)/2, a(n) = floor [c*n!-(n+1)/2] for n>=2.

A026243 a(n) = A000522(n) - 2.

Original entry on oeis.org

0, 3, 14, 63, 324, 1955, 13698, 109599, 986408, 9864099, 108505110, 1302061343, 16926797484, 236975164803, 3554627472074, 56874039553215, 966858672404688, 17403456103284419, 330665665962403998, 6613313319248079999, 138879579704209680020, 3055350753492612960483
Offset: 1

Views

Author

N. J. A. Sloane, based on a message from a correspondent who wishes to remain anonymous, Dec 21 2003

Keywords

Comments

Number of operations of addition and multiplication needed to evaluate a determinant of order n by cofactor expansion.

Examples

			To calculate a determinant of order 3:
    |a b c|       |e f|       |d f|       |d e|
D = |d e f| = a * |h i| - b * |g i| + c * |g h| =
    |g h i|
   = a * (e*i - f*h) - b * (d*i - f*g) + c * (d*h - e*g).
There are 9 multiplications * and 5 additions (+ or -), so 14 operations and a(3) = 14. - _Bernard Schott_, Apr 21 2019
		

Crossrefs

Cf. A000522, A007526. Equals A033312 + A038156.
Cf. A001339.

Programs

  • Maple
    a:= proc(n) a(n):= n*(a(n-1)+2)-1: end: a(1):= 0:
    seq (a(n), n=1..30);  # Alois P. Heinz, May 25 2012
  • Mathematica
    Table[E*Gamma[n+1, 1] - 2, {n, 1, 30}] (* Jean-François Alcover, May 18 2018 *)

Formula

a(n) = n*(a(n-1)+2)-1 for n>1, a(1) = 0. - Alois P. Heinz, May 25 2012
Conjecture: a(n) +(-n-2)*a(n-1) +(2*n-1)*a(n-2) +(-n+2)*a(n-3)=0. - R. J. Mathar, Jun 23 2013 [Confirmed by Altug Alkan, May 18 2018]
a(n) = floor(e*n!) - 2. - Bernard Schott, Apr 21 2019

A080049 Operation count to create all permutations of n distinct elements using Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2. Sequence gives number of interchange operations in step L4.

Original entry on oeis.org

0, 2, 11, 63, 388, 2734, 21893, 197069, 1970726, 21678036, 260136487, 3381774403, 47344841720, 710172625898, 11362762014473, 193166954246169, 3477005176431178, 66063098352192544, 1321261967043851051, 27746501307920872271, 610423028774259190172, 14039729661807961374198
Offset: 2

Views

Author

Hugo Pfoertner, Jan 24 2003

Keywords

References

  • Donald E. Knuth: The Art of Computer Programming, Volume 4, Fascicle 2, Generating All Tuples and Permutations. Addison-Wesley (2005). Chapter 7.2.1.2, 39-40.

Crossrefs

Programs

  • Fortran
    c FORTRAN program available at Pfoertner link.

Formula

a(2)=0, a(n)=n*a(n-1) + (n-1)*floor((n-1)/2).
c = limit n ->infinity a(n)/n! = 0.5430806.. = (e+1/e)/2-1 = A073743 - 1.
a(n) = floor (c*n! - (n-1)/2) for n>=2.

A121662 Triangle read by rows: T(i,j) for the recurrence T(i,j) = (T(i-1,j) + 1)*i.

Original entry on oeis.org

1, 4, 2, 15, 9, 3, 64, 40, 16, 4, 325, 205, 85, 25, 5, 1956, 1236, 516, 156, 36, 6, 13699, 8659, 3619, 1099, 259, 49, 7, 109600, 69280, 28960, 8800, 2080, 400, 64, 8, 986409, 623529, 260649, 79209, 18729, 3609, 585, 81, 9, 9864100, 6235300, 2606500, 792100, 187300, 36100, 5860, 820, 100, 10
Offset: 1

Views

Author

Thomas Wieder, Aug 15 2006

Keywords

Comments

The first column is A007526 = "the number of (nonnull) "variations" of n distinct objects, namely the number of permutations of nonempty subsets of {1,...,n}." E.g. for n=3 there are 15 subsets: {a}, {b}, {c}, {ab}, {ba}, {ac}, {ca}, {bc}, {cb}, {abc}, {acb}, {bac}, {bca}, {cab}, {cba}. These are subsets with a number of elements l=1,...,n. The second column excludes all subsets with l=n elements. For n=3 one has therefore only the 9 subsets {a}, {b}, {c}, {ab}, {ba}, {ac}, {ca}, {bc}, {cb}. The third column excludes all subsets with l>=n-1 elements. For n=3 one has therefore only the 3 subsets {a}, {b},{c}. See also A121684. The second column is A038156 = n!*Sum(1/k!, k=1..n-1). The first lower diagonal are the squares A000290 = n^2. The second lower diagonal (15, 40, 85...) is A053698 = n^3 + n^2 + n + 1. The row sum is A030297 = a(n) = n*(n+a(n-1)).
T(i, j) is the total number of ordered sets of size 1 to i-j+1 that can be created from i distinct items. - Manfred Boergens, Jun 22 2022

Examples

			Triangle T(i,j) begins:
       1
       4     2
      15     9     3
      64    40    16     4
     325   205    85    25    5
    1956  1236   516   156   36   6
   13699  8659  3619  1099  259  49  7
   ...
		

Crossrefs

Mirror of triangle A285268.

Programs

  • Maple
    T:= proc(i, j) option remember;
          `if`(j<1 or j>i, 0, T(i-1, j)*i+i)
        end:
    seq(seq(T(n, k), k=1..n), n=1..10);  # Alois P. Heinz, Jun 22 2022
  • Mathematica
    Table[Sum[m!/(m - i)!, {i, n}], {m, 9}, {n, m, 1, -1}] // Flatten (* Michael De Vlieger, Apr 22 2017 *)
    (* Sum-free code *)
    b[j_] = If[j == 0, 0, Floor[j! E - 1]];
    T[i_, j_] = b[i] - i! b[j - 1]/(j - 1)!;
    Table[T[i, j], {i, 24}, {j, i}] // Flatten
    (* Manfred Boergens, Jun 22 2022 *)

Formula

From Manfred Boergens, Jun 22 2022: (Start)
T(i, j) = Sum_{k=1..i-j+1} i!/(i-k)! = Sum_{k=j-1..i-1} i!/k!.
Sum-free formula: T(i, j) = b(i) - i!*b(j-1)/(j-1)! where b(0)=0, b(j)=floor(j!*e-1) for j>0.
(End)

Extensions

Edited by N. J. A. Sloane, Sep 15 2006
Formula in name corrected by Alois P. Heinz, Jun 22 2022

A268219 a(n) = (n!/4!)*Sum(1/k!,k=1..n-4).

Original entry on oeis.org

0, 0, 0, 0, 0, 5, 45, 350, 2870, 25956, 259770, 2857800, 34294095, 445823950, 6241536301, 93623045880, 1497968735900, 25465468512680, 458378433231300, 8709190231398576, 174183804627976365, 3657859897187509650, 80472917738125219615, 1850877107976880060000, 44421050591445121450626
Offset: 0

Views

Author

N. J. A. Sloane, Jan 30 2016

Keywords

Crossrefs

For others in this series, see A038156, A038158, A268218, A268220.

Programs

  • Maple
    g:=(r,n)->(n!/r!)*add(1/k!,k=1..n-r);
    g2:=r->[seq(g(r,n),n=0..30)];
    g2(4);
  • PARI
    a(n) = (n!/4!)*sum(k=1, n-4, 1/k!); \\ Michel Marcus, Jan 30 2016
Showing 1-10 of 19 results. Next