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.

Previous Showing 31-40 of 73 results. Next

A007709 Number of winning (or reformed) decks at Mousetrap.

Original entry on oeis.org

1, 1, 2, 6, 15, 84, 330, 1812, 9978, 65503, 449719, 3674670, 28886593, 266242729, 2527701273, 25749021720
Offset: 1

Views

Author

Keywords

References

  • A. M. Bersani, "Reformed permutations in Mousetrap and its generalizations," Preprint Me.Mo.Mat. n. 15/2005.
  • 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 and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Extensions

Better description and more terms from Alberto M. Bersani (bersani(AT)dmmm.uniroma1.it), Feb 09 2007
One more term from Alberto M. Bersani (bersani(AT)dmmm.uniroma1.it), Feb 24 2008

A207819 Number of permutations of [n] with a fixed point and/or a succession.

Original entry on oeis.org

0, 1, 1, 6, 20, 106, 618, 4358, 34836, 313592, 3135988, 34498646, 414007634, 5382362086, 75356174332, 1130382058576, 18086649408624, 307480839465174, 5534775895914982, 105162728081809146, 2103289132221173216, 44169707042511725964, 971745847021319655464, 22350404337704558809666, 536415027665581568375190, 13410494347081333360291850
Offset: 0

Views

Author

Jon Perry, Jan 10 2013

Keywords

Comments

A succession of a permutation p is the appearance of [k,k+1], e.g. in 23541, 23 is a succession.

Examples

			For n=4 the only permutations that do not count are 2143, 2413, 3142 and 4321, so a(4) = 4!-4 = 20.
		

Crossrefs

Programs

  • Mathematica
    F[{}] = 1; F[S_] := Sum[G[S ~Complement~ {s}, s-1], {s, S ~Complement~ {Length[S]}}];
    G[{}, ] = 1; G[S, t_] := G[S, t] = Sum[G[S ~Complement~ {s}, s-1], {s, S ~Complement~ {t, Length[S]}}];
    Table[a[n] = n! - F[Range[n]]; Print[n, " ", a[n]]; a[n], {n, 0, 20}] (* Jean-François Alcover, Mar 05 2019, using Robert Israel's code for A209322 *)
  • PARI
    A207819(n)={my(p,c);sum(k=1,n!,p=numtoperm(n,k);(c=(p[1]==1)) || for(j=2,n,p[j]!=j & p[j]-1!=p[j-1] & next; c++; break);c)} \\ M. F. Hasler, Jan 13 2013

Formula

a(n) = n! - A209322(n). - Robert Israel, Mar 27 2017

Extensions

Values a(1..10) double-checked by M. F. Hasler, Jan 13 2013
a(11)-a(14) from Alois P. Heinz, Jan 15 2013
a(15)-a(20) from Robert Israel, Mar 27 2017
a(21)-a(23) from Alois P. Heinz, Jul 04 2021
Terms a(24) onward from Max Alekseyev, Apr 03 2025

A207821 Number of permutations of [n] that either have a fixed point or a succession, but not both.

Original entry on oeis.org

0, 1, 0, 5, 12, 69, 370, 2609, 20552, 183249, 1817794, 19867793, 237126320, 3068483277, 42788761294, 639619513669, 10202914060472, 172984071549421, 3106257794721534, 58892020126278457, 1175554242034515780, 24643158882899363129, 541279064964716455230, 12431122899361840993737, 297944099946417376956220, 7439329384072966947792437
Offset: 0

Views

Author

Jon Perry, Jan 10 2013

Keywords

Comments

A succession of a permutation p is the appearance of [k,k+1], e.g. in 23541, 23 is a succession.

Examples

			a(4) = 12 because we have 1324, 1432, 2341, 2431, 3214, 3241, 3412, 3421, 4123, 4132, 4213 and 4312.
		

Crossrefs

Programs

  • PARI
    A207821(n)=my(p,c);sum(k=1,n!,p=numtoperm(n,k);c=(p[1]==1);for(j=2,n,p[j]==j & c<=0 & !c++ & break; p[j]-1==p[j-1] & c>=0 & !c-- & break); c!=0) \\ M. F. Hasler, Jan 13 2013

Formula

a(n) = A209325(n) + A209326(n) = A000166(n) + A000255(n-1) - 2*A209322(n) = 2*A207819(n) - A180191(n) - A002467(n). - Max Alekseyev, Apr 03 2025

Extensions

Values a(1) to a(10) double-checked by M. F. Hasler, Jan 13 2013
Inserted a(0) and a(11)-a(13) from Alois P. Heinz, Jan 18 2013
a(14)-a(20) from Alois P. Heinz, Jul 05 2021
Terms a(21) onward from Max Alekseyev, Apr 03 2025

A299789 Number T(n,k) of permutations p of [n] such that min_{j=1..n} |p(j)-j| = k; triangle T(n,k), n >= 0, 0 <= k <= floor(n/2), read by rows.

Original entry on oeis.org

0, 1, 1, 1, 4, 2, 15, 8, 1, 76, 40, 4, 455, 236, 28, 1, 3186, 1648, 198, 8, 25487, 13125, 1596, 111, 1, 229384, 117794, 14534, 1152, 16, 2293839, 1175224, 146372, 12929, 435, 1, 25232230, 12903874, 1621282, 152430, 6952, 32, 302786759, 154615096, 19563257, 1922364, 112416, 1707, 1
Offset: 0

Views

Author

Alois P. Heinz, Jan 21 2019

Keywords

Examples

			T(4,0) = 15: 1234, 1243, 1324, 1342, 1423, 1432, 2134, 2314, 2431, 3124, 3214, 3241, 4132, 4213, 4231.
T(4,1) = 8: 2143, 2341, 2413, 3142, 3421, 4123, 4312, 4321.
T(4,2) = 1: 3412.
T(5,2) = 4: 34512, 34521, 45123, 54123.
T(6,3) = 1: 456123.
T(7,3) = 8: 4567123, 4567132, 4567213, 4567231, 5671234, 5761234, 6571234, 7561234.
T(8,4) = 1: 56781234.
T(9,4) = 16: 567891234, 567891243, 567891324, 567891342, 567892134, 567892143, 567892314, 567892341, 678912345, 679812345, 687912345, 697812345, 768912345, 769812345, 867912345, 967812345.
Triangle T(n,k) begins:
          0;
          1;
          1,         1;
          4,         2;
         15,         8,        1;
         76,        40,        4;
        455,       236,       28,       1;
       3186,      1648,      198,       8;
      25487,     13125,     1596,     111,      1;
     229384,    117794,    14534,    1152,     16;
    2293839,   1175224,   146372,   12929,    435,    1;
   25232230,  12903874,  1621282,  152430,   6952,   32;
  302786759, 154615096, 19563257, 1922364, 112416, 1707, 1;
  ...
		

Crossrefs

Columns k=0-1 give: A002467, A296050.
Row sums give A000142 (for n>0).
T(2n,n) gives A057427.
T(2n+1,n) gives A000079.
T(2n+2,n) gives A306545.

Programs

  • Maple
    b:= proc(s) option remember; (n-> `if`(n=1, x^(s[1]-1),
          add((p-> add(coeff(p, x, i)*x^min(i, abs(n-j)),
          i=0..degree(p)))(b(s minus {j})), j=s)))(nops(s))
        end:
    T:= n-> (p-> seq(coeff(p, x, i), i=0..max(0, degree(p))))(b({$1..n})):
    seq(T(n), n=0..14);
    # second Maple program:
    A:= proc(n, k) option remember; `if`(n=0, 0, LinearAlgebra[
          Permanent](Matrix(n, (i, j)-> `if`(abs(i-j)>=k, 1, 0))))
        end:
    T:= (n, k)-> A(n, k)-A(n, k+1):
    seq(seq(T(n, k), k=0..n/2), n=0..14);
  • Mathematica
    A[n_, k_] := A[n, k] = If[n==0, 0, Permanent[Table[If[Abs[i-j] >= k, 1, 0], {i, 1, n}, {j, 1, n}]]];
    T[n_, k_] := A[n, k] - A[n, k+1];
    Table[T[n, k], {n, 0, 14}, {k, 0, n/2}] // Flatten (* Jean-François Alcover, May 01 2019, from 2nd Maple program *)

Formula

T(n,k) = A306543(n,k) - A306543(n,k+1) for n > 0.
Sum_{k=1..floor(n/2)} k * T(n,k) = A129118(n).
Sum_{k=1..floor(n/2)} T(n,k) = A000166(n).
Sum_{k=2..floor(n/2)} T(n,k) = A001883(n).
Sum_{k=3..floor(n/2)} T(n,k) = A075851(n).
Sum_{k=4..floor(n/2)} T(n,k) = A075852(n).

A306506 Number T(n,k) of permutations p of [n] having at least one index i with |p(i)-i| = k; triangle T(n,k), n>=1, 0<=k<=n-1, read by rows.

Original entry on oeis.org

1, 1, 1, 4, 4, 3, 15, 19, 15, 10, 76, 99, 86, 67, 42, 455, 603, 544, 455, 358, 216, 3186, 4248, 3934, 3486, 2921, 2250, 1320, 25487, 34115, 32079, 29296, 25487, 21514, 16296, 9360, 229384, 307875, 292509, 272064, 245806, 214551, 179058, 133800, 75600
Offset: 1

Views

Author

Alois P. Heinz, Feb 20 2019

Keywords

Comments

T(n,k) is defined for n,k>=0. The triangle contains only the terms with k=n.

Examples

			The 6 permutations p of [3]: 123, 132, 213, 231, 312, 321 have absolute displacement sets {|p(i)-i|, i=1..3}: {0}, {0,1}, {0,1}, {1,2}, {1,2}, {0,2}, respectively. Number 0 occurs four times, 1 occurs four times, and 2 occurs thrice. So row n=3 is [4, 4, 3].
Triangle T(n,k) begins:
      1;
      1,     1;
      4,     4,     3;
     15,    19,    15,    10;
     76,    99,    86,    67,    42;
    455,   603,   544,   455,   358,   216;
   3186,  4248,  3934,  3486,  2921,  2250,  1320;
  25487, 34115, 32079, 29296, 25487, 21514, 16296, 9360;
  ...
		

Crossrefs

Columns k=0-3 give: A002467, A306511, A306524, A324366.
T(n+2,n+1) gives A007680 (for n>=0).
T(2n,n) gives A306675.

Programs

  • Maple
    b:= proc(s, d) option remember; (n-> `if`(n=0, add(x^j, j=d),
          add(b(s minus {i}, d union {abs(n-i)}), i=s)))(nops(s))
        end:
    T:= n-> (p-> seq(coeff(p, x, i), i=0..n-1))(b({$1..n}, {})):
    seq(T(n), n=1..9);
    # second Maple program:
    T:= proc(n, k) option remember; n!-LinearAlgebra[Permanent](
          Matrix(n, (i, j)-> `if`(abs(i-j)=k, 0, 1)))
        end:
    seq(seq(T(n, k), k=0..n-1), n=1..9);
  • Mathematica
    T[n_, k_] := n!-Permanent[Table[If[Abs[i-j]==k, 0, 1], {i, 1, n}, {j, 1, n} ]];
    Table[T[n, k], {n, 1, 9}, {k, 0, n-1}] // Flatten (* Jean-François Alcover, May 01 2019, from 2nd Maple program *)

Formula

T(n,k) = n! - A306512(n,k).
T(2n,n) = T(2n,0) = A002467(2n) = (2n)! - A306535(n).

A209322 Number of derangements of [n] with no succession.

Original entry on oeis.org

1, 0, 1, 0, 4, 14, 102, 682, 5484, 49288, 492812, 5418154, 64993966, 844658714, 11822116868, 177292309424, 2836140479376, 48206588630826, 867597809813018, 16482372327022854, 329612875955466784, 6921235129197714036, 152254880756288024536, 3501612401180417830334, 84033374067657870984810, 2100715696249652623708150
Offset: 0

Views

Author

Jon Perry, Jan 19 2013

Keywords

Comments

A derangement is a permutation with no fixed points. A succession of a permutation p is a position i such that p(i+1)-p(i) = 1.

Examples

			For n=4 we have 2143, 2413, 3142 and 4321, so a(4) = 4.
		

Crossrefs

Programs

  • Maple
    F:= proc(S) add(G(S minus {s}, s-1), s = S minus {nops(S)}) end proc:
    G:= proc(S,t) option remember;
    if S = {} then return 1 fi;
    add(procname(S minus {s},s-1), s = S minus {t, nops(S)})
    end proc:
    1,seq(F({$1..n}), n=1..19); # Robert Israel, Mar 02 2017
  • Mathematica
    F[{}] = 1; F[S_] := Sum[G[S ~Complement~ {s}, s-1], {s, S ~Complement~ {Length[S]}}];
    G[{}, ] = 1; G[S, t_] := G[S, t] = Sum[G[S ~Complement~ {s}, s-1], {s, S ~Complement~ {t, Length[S]}}];
    Table[a[n] = F[Range[n]]; Print[n, " ", a[n]]; a[n], {n, 0, 20}] (* Jean-François Alcover, Mar 05 2019, after Robert Israel *)
  • PARI
    { a209322(n) = if(n==0, return(1)); my(A=matrix(n, n, i, j, i-j!=1 && i!=j)); parsum(s=1, 2^n-1, my(M=vecextract(A, s, s), d=matsize(M)[1], v=vectorv(d, i, 1), pos=bitand(s, 1)); if(pos, v[1]=0); for(k=1, n-1, v=M*v; if(bitand(s>>k, 1), v[pos++]=0)); (-1)^(n-d)*vecsum(v) ); } \\ Max Alekseyev, Apr 03 2025

Formula

a(n) = n! - A207819(n).

Extensions

a(11)-a(14) from Alois P. Heinz, Jan 19 2013
a(15)-a(20) from Robert Israel, Mar 02 2017
a(21)-a(23) from Alois P. Heinz, Jul 04 2021
Terms a(24) onward from Max Alekseyev, Apr 03 2025

A306461 Number T(n,k) of occurrences of k in a (signed) displacement set of a permutation of [n]; triangle T(n,k), n>=1, 1-n<=k<=n-1, read by rows.

Original entry on oeis.org

1, 1, 1, 1, 2, 3, 4, 3, 2, 6, 10, 13, 15, 13, 10, 6, 24, 42, 56, 67, 76, 67, 56, 42, 24, 120, 216, 294, 358, 411, 455, 411, 358, 294, 216, 120, 720, 1320, 1824, 2250, 2612, 2921, 3186, 2921, 2612, 2250, 1824, 1320, 720, 5040, 9360, 13080, 16296, 19086, 21514, 23633, 25487, 23633, 21514, 19086, 16296, 13080, 9360, 5040
Offset: 1

Views

Author

Alois P. Heinz, Feb 17 2019

Keywords

Examples

			The 6 permutations p of [3]: 123, 132, 213, 231, 312, 321 have (signed) displacement sets {p(i)-i, i=1..3}: {0}, {-1,0,1}, {-1,0,1}, {-2,1}, {-1,2}, {-2,0,2}, respectively. Numbers -2 and 2 occur twice, -1 and 1 occur thrice, and 0 occurs four times. So row n=3 is [2, 3, 4, 3, 2].
Triangle T(n,k) begins:
  :                             1                           ;
  :                        1,   1,   1                      ;
  :                   2,   3,   4,   3,   2                 ;
  :              6,  10,  13,  15,  13,  10,   6            ;
  :        24,  42,  56,  67,  76,  67,  56,  42,  24       ;
  :  120, 216, 294, 358, 411, 455, 411, 358, 294, 216, 120  ;
		

Crossrefs

Columns k=0-1 give: A002467, A180191.
Row sums give A306455.
T(n+1,n) gives A000142.
T(n+2,n) gives A007680.
Cf. A000142, A061018 (left half of this triangle), A306234, A306506, A324225.

Programs

  • Maple
    b:= proc(s, d) option remember; (n-> `if`(n=0, add(x^j, j=d),
          add(b(s minus {i}, d union {n-i}), i=s)))(nops(s))
        end:
    T:= n-> (p-> seq(coeff(p, x, i), i=1-n..n-1))(b({$1..n}, {})):
    seq(T(n), n=1..8);
    # second Maple program:
    T:= (n, k)-> -add((-1)^j*binomial(n-abs(k), j)*(n-j)!, j=1..n):
    seq(seq(T(n, k), k=1-n..n-1), n=1..9);
  • Mathematica
    T[n_, k_] := -Sum[(-1)^j Binomial[n-Abs[k], j] (n-j)!, {j, 1, n}];
    Table[Table[T[n, k], {k, 1-n, n-1}], {n, 1, 9}] // Flatten (* Jean-François Alcover, Feb 20 2021, after Alois P. Heinz *)

Formula

T(n,k) = T(n,-k).
T(n,k) = - Sum_{j=1..n} (-1)^j * binomial(n-|k|,j) * (n-j)!.
T(n,k) = |k|! * (n-|k|)! [x^(n-|k|)] (1-exp(-x))/(1-x)^(|k|+1).
Sum_{k=1-n..n-1} T(n,k) = A306455(n).
T(n,k) = |k|! * A306234(n,k).

A007711 Number of unreformed permutations of {1,...,n}.

Original entry on oeis.org

0, 1, 4, 18, 105, 636, 4710, 38508, 352902, 3563297, 39467081, 475326930, 6198134207, 86912048471, 1305146666727, 20897040866280
Offset: 1

Views

Author

Keywords

Examples

			For n=3, the 4 unreformed permutations are 123, 231, 312, 213, so a(3)=4. Also 132->123, 321->213 are reformable.
		

References

  • A. M. Bersani, "Reformed permutations in Mousetrap and its generalizations", preprint MeMoMat n. 15/2005.
  • 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 and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Formula

a(n) = n! - A007709(n). - Sean A. Irvine, Jan 17 2018

Extensions

More terms from Kok Seng Chua (chuaks(AT)ihpc.nus.edu.sg), Mar 06 2002
2 more terms from Alberto M. Bersani (bersani(AT)dmmm.uniroma1.it), Feb 07 2007
One more term from Alberto M. Bersani (bersani(AT)dmmm.uniroma1.it), Feb 24 2008
a(1) corrected by Joerg Arndt, Dec 24 2014

A007712 Number of once reformable permutations of {1,2,...,n}.

Original entry on oeis.org

1, 2, 4, 14, 72, 316, 1730, 9728, 64330, 444890, 3645441, 28758111, 265434293, 2522822881, 25717118338
Offset: 2

Views

Author

Keywords

Examples

			For n=3, 123, 312, 231, 213 are unreformed but 132->123, 321->213 so a(3)=2.
		

References

  • A. M. Bersani, "Reformed permutations in Mousetrap and its generalizations", preprint MeMoMat, No. 15, 2005.
  • R. K. Guy, Unsolved Problems Number Theory, Section 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 and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Extensions

More terms from Kok Seng Chua (chuaks(AT)ihpc.nus.edu.sg), Mar 06 2002
2 more terms from Alberto M. Bersani (bersani(AT)dmmm.uniroma1.it), Feb 07 2007
One more term from Alberto M. Bersani (bersani(AT)dmmm.uniroma1.it), Feb 24 2008

A052169 Equivalent of the Kurepa hypothesis for left factorial.

Original entry on oeis.org

1, 2, 5, 19, 91, 531, 3641, 28673, 254871, 2523223, 27526069, 328018989, 4239014627, 59043418019, 881715042417, 14052333488521, 238063061452591, 4271909380510383, 80941440893880941, 1614781745832924773, 33833522293642233339, 742799603083145395579
Offset: 2

Views

Author

Aleksandar Petojevic, Jan 26 2000

Keywords

Crossrefs

Pairwise sums of A002467.

Programs

  • Maple
    a[2] := 1: a[3] := 2: for n from 4 to 21 do a[n] := (n-2)*a[n-1]+(n-3)*a[n-2] end do: seq(a[n], n = 2 .. 21); # Emeric Deutsch, Jun 15 2009
    # second Maple program:
    a:= proc(n) option remember; `if`(n<4, n-1,
          (n-2)*a(n-1)+(n-3)*a(n-2))
        end:
    seq(a(n), n=2..25);  # Alois P. Heinz, Aug 30 2016
  • Mathematica
    Numerator[k=1; NestList[1+1/(k++ #1)&,1,12]] (* Wouter Meeussen, Mar 24 2007 *)
    a[n_] := (n! - Subfactorial[n])/(n-1); Table[a[n], {n, 2, 23}] (* Jean-François Alcover, Jul 21 2017, after Emeric Deutsch's comment *)
  • Sage
    from sage.combinat.sloane_functions import ExtremesOfPermanentsSequence2 ; e = ExtremesOfPermanentsSequence2() ; it = e.gen(1,2,1) ; [next(it) for i in range(20)] #(5 rows) # Zerinvary Lajos, May 15 2009

Formula

a(2) = 1, a(3) = 2, a(n) = (n-2)*a(n-1) + (n-3)*a(n-2).
a(n) = A002467(n)/(n-1) (A002467(n) = number of non-derangements of {1,2,...,n}). - Emeric Deutsch, Jun 15 2009
a(n) = 2*floor((n+1)!*(n+3)/e+1/2) - 3*(floor(((n+1)!+1)/e)+ floor(((n+2)!+1)/e)) +(n+1)!+(n+2)!, n>1, with offset 0..a(0)= 1. - Gary Detlefs, Apr 18 2010
a(n) = 1/(n+1)*((n+2)!-floor(((n+2)!+1)/e)), with offset 0 a(n) = 1/(n-1)*(n! - floor((n!+1)/e)). - Gary Detlefs, Jul 11 2010
From Benedict W. J. Irwin, Jun 02 2016: (Start)
Let y(-1)=1, y(0)=1, and y(n) = (Sum_{k=0..n-1} y(k)+y(k-1))/n,
a(n) = (n-2)!*y(n-2).
(End)
a(n) = (Gamma(n+1,0)-exp(-1)*Gamma(n+1,-1))/(n-1). - Martin Clever, Mar 25 2023

Extensions

More terms from James Sellers, Jan 31 2000
Previous Showing 31-40 of 73 results. Next