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

A001250 Number of alternating permutations of order n.

Original entry on oeis.org

1, 1, 2, 4, 10, 32, 122, 544, 2770, 15872, 101042, 707584, 5405530, 44736512, 398721962, 3807514624, 38783024290, 419730685952, 4809759350882, 58177770225664, 740742376475050, 9902996106248192, 138697748786275802, 2030847773013704704, 31029068327114173810
Offset: 0

Views

Author

Keywords

Comments

For n>1, a(n) is the number of permutations of order n with the length of longest run equal 2.
Boustrophedon transform of the Euler numbers (A000111). [Berry et al., 2013] - N. J. A. Sloane, Nov 18 2013
Number of inversion sequences of length n where all consecutive subsequences i,j,k satisfy i >= j < k or i < j >= k. a(4) = 10: 0010, 0011, 0020, 0021, 0022, 0101, 0102, 0103, 0112, 0113. - Alois P. Heinz, Oct 16 2019

Examples

			1 + x + 2*x^2 + 4*x^3 + 10*x^4 + 32*x^5 + 122*x^6 + 544*x^7 + 2770*x^8 + ...
From _Gus Wiseman_, Jun 21 2021: (Start)
The a(0) = 1 through a(4) = 10 permutations:
  ()  (1)  (1,2)  (1,3,2)  (1,3,2,4)
           (2,1)  (2,1,3)  (1,4,2,3)
                  (2,3,1)  (2,1,4,3)
                  (3,1,2)  (2,3,1,4)
                           (2,4,1,3)
                           (3,1,4,2)
                           (3,2,4,1)
                           (3,4,1,2)
                           (4,1,3,2)
                           (4,2,3,1)
(End)
		

References

  • L. Comtet, Advanced Combinatorics, Reidel, 1974, p. 261.
  • F. N. David, M. G. Kendall and D. E. Barton, Symmetric Function and Allied Tables, Cambridge, 1966, p. 262.
  • 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

Cf. A000111. A diagonal of A010094.
The version for permutations of prime indices is A345164.
The version for compositions is A025047, ranked by A345167.
The version for patterns is A345194.
A049774 counts permutations avoiding adjacent (1,2,3).
A344614 counts compositions avoiding adjacent (1,2,3) and (3,2,1).
A344615 counts compositions avoiding the weak adjacent pattern (1,2,3).
A344654 counts partitions without a wiggly permutation, ranked by A344653.
A345170 counts partitions with a wiggly permutation, ranked by A345172.
A345192 counts non-wiggly compositions, ranked by A345168.
Row sums of A104345.

Programs

  • Haskell
    a001250 n = if n == 1 then 1 else 2 * a000111 n
    -- Reinhard Zumkeller, Sep 17 2014
    
  • Maple
    # With Eulerian polynomials:
    A := (n, x) -> `if`(n<2, 1/2/(1+I)^(1-n), add(add((-1)^j*binomial(n+1, j)*(m+1-j)^n, j=0..m)*x^m, m=0..n-1)):
    A001250 := n -> 2*(I-1)^(1-n)*exp(I*(n-1)*Pi/2)*A(n,I);
    seq(A001250(i), i=0..22); # Peter Luschny, May 27 2012
    # second Maple program:
    b:= proc(u, o) option remember;
          `if`(u+o=0, 1, add(b(o-1+j, u-j), j=1..u))
        end:
    a:= n-> `if`(n<2, 1, 2)*b(n, 0):
    seq(a(n), n=0..30);  # Alois P. Heinz, Nov 29 2015
  • Mathematica
    a[n_] := 4*Abs[PolyLog[-n, I]]; a[0] = a[1] = 1; Table[a[n], {n, 0, 25}] (* Jean-François Alcover, Jan 09 2016, after M. F. Hasler *)
    Table[Length[Select[Permutations[Range[n]],And@@(!(OrderedQ[#]||OrderedQ[Reverse[#]])&/@Partition[#,3,1])&]],{n,8}] (* Gus Wiseman, Jun 21 2021 *)
    a[0]:=1; a[1]:=1; a[n_]:=a[n]=1/(n (n-1)) Sum[a[n-1-k] a[k] k, {k,1, n-1}]; Join[{a[0], a[1]}, Map[2 #! a[#]&, Range[2,24]]] (* Oliver Seipel, May 27 2024 *)
  • PARI
    {a(n) = local(v=[1], t); if( n<0, 0, for( k=2, n+3, t=0; v = vector( k, i, if( i>1, t += v[k+1 - i]))); v[3])} /* Michael Somos, Feb 03 2004 */
    
  • PARI
    {a(n) = if( n<0, 0, n! * polcoeff( (tan(x + x * O(x^n)) + 1 / cos(x + x * O(x^n)))^2, n))} /* Michael Somos, Feb 05 2011 */
    
  • PARI
    A001250(n)=sum(m=0,n\2,my(k);(-1)^m*sum(j=0,k=n+1-2*m,binomial(k,j)*(-1)^j*(k-2*j)^(n+1))/k>>k)*2-(n==1)  \\ M. F. Hasler, May 19 2012
    
  • PARI
    A001250(n)=4*abs(polylog(-n,I))-(n==1)  \\ M. F. Hasler, May 20 2012
    
  • PARI
    my(x='x+O('x^66), egf=1+2*(tan(x)+1/cos(x))-2-x); Vec(serlaplace(egf)) /* Joerg Arndt, May 28 2012 */
    
  • Python
    from itertools import accumulate, islice
    def A001250_gen(): # generator of terms
        yield from (1,1)
        blist = (0,2)
        while True:
            yield (blist := tuple(accumulate(reversed(blist),initial=0)))[-1]
    A001250_list = list(islice(A001250_gen(),40)) # Chai Wah Wu, Jun 09-11 2022
    
  • Python
    from sympy import bernoulli, euler
    def A001250(n): return 1 if n<2 else abs(((1<Chai Wah Wu, Nov 13 2024
  • Sage
    # Algorithm of L. Seidel (1877)
    def A001250_list(n) :
        R = [1]; A = {-1:0, 0:2}; k = 0; e = 1
        for i in (0..n) :
            Am = 0; A[k + e] = 0; e = -e
            for j in (0..i) : Am += A[k]; A[k] = Am; k += e
            if i > 1 : R.append(A[-i//2] if i%2 == 0 else A[i//2])
        return R
    A001250_list(22) # Peter Luschny, Mar 31 2012
    

Formula

a(n) = coefficient of x^(n-1)/(n-1)! in power series expansion of (tan(x) + sec(x))^2 = (tan(x)+1/cos(x))^2.
a(n) = coefficient of x^n/n! in power series expansion of 2*(tan(x) + sec(x)) - 2 - x. - Michael Somos, Feb 05 2011
For n>1, a(n) = 2 * A000111(n). - Michael Somos, Mar 19 2011
a(n) = 4*|Li_{-n}(i)| - [n=1] = Sum_{m=0..n/2} (-1)^m*2^(1-k)*Sum_{j=0..k} binomial(k,j)*(-1)^j*(k-2*j)^(n+1)/k - [n=1], where k = k(m) = n+1-2*m and [n=1] equals 1 if n=1 and zero else; Li denotes the polylogarithm (and i^2 = -1). - M. F. Hasler, May 20 2012
From Sergei N. Gladkovskii, Jun 18 2012: (Start)
Let E(x) = 2/(1-sin(x))-1 (essentially the e.g.f.), then
E(x) = -1 + 2*(-1/x + 1/(1-x)/x - x^3/((1-x)*((1-x)*G(0) + x^2))) where G(k) = (2*k+2)*(2*k+3)-x^2+(2*k+2)*(2*k+3)*x^2/G(k+1); (continued fraction, Euler's 1st kind, 1-step).
E(x) = -1 + 2*(-1/x + 1/(1-x)/x - x^3/((1-x)*((1-x)*G(0) + x^2))) where G(k) = 8*k + 6 - x^2/(1 + (2*k+2)*(2*k+3)/G(k+1)); (continued fraction, Euler's 2nd kind, 2-step).
E(x) = (tan(x) + sec(x))^2 = -1 + 2/(1-x*G(0)) where G(k) = 1 - x^2/(2*(2*k+1)*(4*k+3) - 2*x^2*(2*k+1)*(4*k+3)/(x^2 - 4*(k+1)*(4*k+5)/G(k+1))); (continued fraction, 3rd kind, 3-step).
(End)
G.f.: conjecture: 2*T(0)/(1-x) -1, where T(k) = 1 - x^2*(k+1)*(k+2)/(x^2*(k+1)*(k+2) - 2*(1-x*(k+1))*(1-x*(k+2))/Q(k+1) ); (continued fraction). - Sergei N. Gladkovskii, Nov 19 2013
a(n) ~ 2^(n+3) * n! / Pi^(n+1). - Vaclav Kotesovec, Sep 06 2014
a(n) = Sum_{k=0..n-1} A109449(n-1,k)*A000111(k). - Reinhard Zumkeller, Sep 17 2014

Extensions

Edited by Max Alekseyev, May 04 2012
a(0)=1 prepended by Alois P. Heinz, Nov 29 2015

A242784 Number A(n,k) of permutations of [n] avoiding the consecutive step pattern given by the binary expansion of k, where 1=up and 0=down; square array A(n,k), n>=0, k>=0, read by antidiagonals.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 4, 1, 1, 1, 1, 2, 5, 8, 1, 1, 1, 1, 2, 6, 17, 16, 1, 1, 1, 1, 2, 6, 21, 70, 32, 1, 1, 1, 1, 2, 6, 19, 90, 349, 64, 1, 1, 1, 1, 2, 6, 21, 70, 450, 2017, 128, 1, 1, 1, 1, 2, 6, 23, 90, 331, 2619, 13358, 256, 1, 1
Offset: 0

Views

Author

Alois P. Heinz, May 22 2014

Keywords

Examples

			A(4,5) = 19 because there are 4! = 24 permutations of {1,2,3,4} and only 5 of them do not avoid the consecutive step pattern up, down, up given by the binary expansion of 5 = 101_2: (1,3,2,4), (1,4,2,3), (2,3,1,4), (2,4,1,3), (3,4,1,2).
Square array A(n,k) begins:
  1, 1,   1,     1,     1,     1,     1,     1,     1, ...
  1, 1,   1,     1,     1,     1,     1,     1,     1, ...
  1, 1,   2,     2,     2,     2,     2,     2,     2, ...
  1, 1,   4,     5,     6,     6,     6,     6,     6, ...
  1, 1,   8,    17,    21,    19,    21,    23,    24, ...
  1, 1,  16,    70,    90,    70,    90,   111,   116, ...
  1, 1,  32,   349,   450,   331,   450,   642,   672, ...
  1, 1,  64,  2017,  2619,  1863,  2619,  4326,  4536, ...
  1, 1, 128, 13358, 17334, 11637, 17334, 33333, 34944, ...
		

Crossrefs

Columns give: 0, 1: A000012, 2: A011782, 3: A049774, 4, 6: A177479, 5: A177477, 7: A117158, 8, 14: A177518, 9: A177519, 10: A177520, 11, 13: A177521, 12: A177522, 15: A177523, 16, 30: A177524, 17: A177525, 18, 22: A177526, 19, 25: A177527, 20, 26: A177528, 21: A177529, 23, 29: A177530, 24, 28: A177531, 27: A177532, 31: A177533, 32, 62: A177534, 33: A177535, 34, 46: A177536, 35, 49: A177537, 36, 54: A177538, 37, 41: A177539, 38: A177540, 39, 57: A177541, 40, 58: A177542, 42: A177543, 43, 53: A177544, 44, 50: A177545, 45: A177546, 47, 61: A177547, 48, 60: A177548, 51: A177549, 52: A177550, 55, 59: A177551, 56: A177552, 63: A177553, 127: A230051, 255: A230231, 511: A230232, 1023: A230233, 2047: A254523.
Main diagonal gives A242785.

Programs

  • Maple
    A:= proc(n, k) option remember; local b, m, r, h;
          if k<2 then return 1 fi;
          m:= iquo(k, 2, 'r'); h:= 2^ilog2(k);
          b:= proc(u, o, t) option remember; `if`(u+o=0, 1,
          `if`(t=m and r=0, 0, add(b(u-j, o+j-1, irem(2*t, h)), j=1..u))+
          `if`(t=m and r=1, 0, add(b(u+j-1, o-j, irem(2*t+1, h)), j=1..o)))
          end; forget(b);
          b(n, 0, 0)
        end:
    seq(seq(A(n, d-n), n=0..d), d=0..15);
  • Mathematica
    Clear[A]; A[n_, k_] := A[n, k] = Module[{b, m, r, h}, If[k < 2, Return[1]]; {m, r} = QuotientRemainder[k, 2]; h = 2^Floor[Log[2, k]]; b[u_, o_, t_] := b[u, o, t] = If[u + o == 0, 1, If[t == m && r == 0, 0, Sum[b[u - j, o + j - 1, Mod[2*t, h]], {j, 1, u}]] + If[t == m && r == 1, 0, Sum[b[u + j - 1, o - j, Mod[2*t + 1, h]], {j, 1, o}]]]; b[n, 0, 0]]; Table[Table[A[n, d - n], {n, 0, d}], {d, 0, 15}] // Flatten (* Jean-François Alcover, Sep 22 2014, translated from Maple *)

A344606 Number of alternating permutations of the prime factors of n, counting multiplicity, including twins (x,x).

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 1, 0, 1, 2, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 2, 2, 1, 0, 1, 2, 0, 1, 1, 4, 1, 0, 2, 2, 2, 2, 1, 2, 2, 0, 1, 4, 1, 1, 1, 2, 1, 0, 1, 1, 2, 1, 1, 0, 2, 0, 2, 2, 1, 4, 1, 2, 1, 0, 2, 4, 1, 1, 2, 4, 1, 1, 1, 2, 1, 1, 2, 4, 1, 0, 0, 2, 1, 4, 2, 2, 2
Offset: 1

Views

Author

Gus Wiseman, May 28 2021

Keywords

Comments

Differs from A335448 in having a(x^2) = 0 and a(270) = 0.
These are permutations of the prime factors of n, counting multiplicity, with no adjacent triples (..., x, y, z, ...) where x <= y <= z or x >= y >= z.
The version without twins (x,x) is A345164, which is identical to this sequence except when n is the square of a prime.

Examples

			The permutations for n = 2, 6, 30, 180, 210, 300, 420, 720, 840:
  2   23   253   23253   2537   25253   23275   2323252   232527
      32   325   32325   2735   25352   25273   2325232   232725
           352   32523   3275   32525   25372   2523232   252327
           523   35232   3527   35252   27253             252723
                 52323   3725   52325   27352             272325
                         5273   52523   32527             272523
                         5372           32725             325272
                         5723           35272             327252
                         7253           37252             523272
                         7352           52327             527232
                                        52723             723252
                                        57232             725232
                                        72325
                                        72523
For example, there are no alternating permutations of the prime factors of 270 because the only anti-runs are {3,2,3,5,3} and {3,5,3,2,3}, neither of which is alternating, so a(270) = 0.
		

Crossrefs

The version for permutations is A001250.
The extension to anti-run permutations is A335452.
The version for compositions is A344604.
The version for patterns is A344605.
Positions of zeros are A344653 (counted by A344654).
Not including twins (x,x) gives A345164.
A008480 counts permutations of prime indices (strict: A335489, rank: A333221).
A056239 adds up prime indices, row sums of A112798.
A071321 and A071322 are signed sums of prime factors.
A316523 is a signed sum of prime multiplicities.
A316524 and A344616 are signed sums of prime indices.
A325534 counts separable partitions (ranked by A335433).
A325535 counts inseparable partitions (ranked by A335448).
A344740 counts partitions with an alternating permutation or twin (x,x).

Programs

  • Mathematica
    Table[Length[Select[Permutations[Flatten[ConstantArray@@@FactorInteger[n]]],!MatchQ[#,{_,x_,y_,z_,_}/;x<=y<=z||x>=y>=z]&]],{n,100}]

A025048 Number of up/down (initially ascending) compositions of n.

Original entry on oeis.org

1, 1, 1, 2, 3, 4, 7, 11, 16, 26, 41, 64, 100, 158, 247, 389, 612, 960, 1509, 2372, 3727, 5858, 9207, 14468, 22738, 35737, 56164, 88268, 138726, 218024, 342652, 538524, 846358, 1330160, 2090522, 3285526, 5163632, 8115323, 12754288, 20045027, 31503382
Offset: 0

Views

Author

Keywords

Comments

Original name was: Ascending wiggly sums: number of sums adding to n in which terms alternately increase and decrease.
A composition is up/down if it is alternately strictly increasing and strictly decreasing, starting with an increase. For example, the partition (3,2,2,2,1) has no up/down permutations, even though it does have the anti-run permutation (2,3,2,1,2). - Gus Wiseman, Jan 15 2022

Examples

			From _Gus Wiseman_, Jan 15 2022: (Start)
The a(1) = 1 through a(7) = 11 up/down compositions:
  (1)  (2)  (3)    (4)      (5)      (6)        (7)
            (1,2)  (1,3)    (1,4)    (1,5)      (1,6)
                   (1,2,1)  (2,3)    (2,4)      (2,5)
                            (1,3,1)  (1,3,2)    (3,4)
                                     (1,4,1)    (1,4,2)
                                     (2,3,1)    (1,5,1)
                                     (1,2,1,2)  (2,3,2)
                                                (2,4,1)
                                                (1,2,1,3)
                                                (1,3,1,2)
                                                (1,2,1,2,1)
(End)
		

Crossrefs

The case of permutations is A000111.
The undirected version is A025047, ranked by A345167.
The down/up version is A025049, ranked by A350356.
The strict case is A129838, undirected A349054.
The weak version is A129852, down/up A129853.
The version for patterns is A350354.
These compositions are ranked by A350355.
A001250 counts alternating permutations, complement A348615.
A003242 counts Carlitz compositions, complement A261983.
A011782 counts compositions, unordered A000041.
A325534 counts separable partitions, complement A325535.
A345192 counts non-alternating compositions, ranked by A345168.
A345194 counts alternating patterns, complement A350252.
A349052 counts weakly alternating compositions, complement A349053.

Programs

  • Mathematica
    updoQ[y_]:=And@@Table[If[EvenQ[m],y[[m]]>y[[m+1]],y[[m]]Gus Wiseman, Jan 15 2022 *)

Formula

a(n) = 1 + A025047(n) - A025049(n) = Sum_k A059882(n,k). - Henry Bottomley, Feb 05 2001
a(n) ~ c * d^n, where d = 1.571630806607064114100138865739690782401305155950789062725011227781640624..., c = 0.4408955566119650057730070154620695491718230084159159991449729825619... . - Vaclav Kotesovec, Sep 12 2014

Extensions

Name and offset changed by Gus Wiseman, Jan 15 2022

A025049 Number of down/up (initially descending) compositions of n.

Original entry on oeis.org

1, 1, 1, 2, 2, 4, 6, 9, 14, 23, 35, 55, 87, 136, 214, 337, 528, 830, 1306, 2051, 3223, 5067, 7962, 12512, 19667, 30908, 48574, 76343, 119982, 188565, 296358, 465764, 732006, 1150447, 1808078, 2841627, 4465992, 7018891, 11031101, 17336823, 27247087, 42822355
Offset: 0

Views

Author

Keywords

Comments

Original name was: Descending wiggly sums: number of sums adding to n in which terms alternately decrease and increase.
A composition is down/up if it is alternately strictly decreasing and strictly increasing, starting with a decrease. For example, the partition (3,2,2,2,1) has no down/up permutations, even though it does have the anti-run permutation (2,1,2,3,2). - Gus Wiseman, Jan 28 2022

Examples

			From _Gus Wiseman_, Jan 28 2022: (Start)
The a(1) = 1 through a(8) = 14 down/up compositions:
  (1)  (2)  (3)    (4)    (5)      (6)        (7)        (8)
            (2,1)  (3,1)  (3,2)    (4,2)      (4,3)      (5,3)
                          (4,1)    (5,1)      (5,2)      (6,2)
                          (2,1,2)  (2,1,3)    (6,1)      (7,1)
                                   (3,1,2)    (2,1,4)    (2,1,5)
                                   (2,1,2,1)  (3,1,3)    (3,1,4)
                                              (4,1,2)    (3,2,3)
                                              (2,1,3,1)  (4,1,3)
                                              (3,1,2,1)  (5,1,2)
                                                         (2,1,3,2)
                                                         (2,1,4,1)
                                                         (3,1,3,1)
                                                         (4,1,2,1)
                                                         (2,1,2,1,2)
(End)
		

Crossrefs

The case of permutations is A000111.
The undirected version is A025047, ranked by A345167.
The up/down version is A025048, ranked by A350355.
The strict case is A129838, undirected A349054.
The weak version is A129853, up/down A129852.
The version for patterns is A350354.
These compositions are ranked by A350356.
A001250 counts alternating permutations, complement A348615.
A003242 counts Carlitz compositions, complement A261983.
A011782 counts compositions, unordered A000041.
A325534 counts separable partitions, complement A325535.
A345192 counts non-alternating compositions, ranked by A345168.
A345194 counts alternating patterns, complement A350252.
A349052 counts weakly alternating compositions, complement A349053.

Programs

  • Mathematica
    doupQ[y_]:=And@@Table[If[EvenQ[m],y[[m]]y[[m+1]]],{m,1,Length[y]-1}];
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],doupQ]],{n,0,15}] (* Gus Wiseman, Jan 28 2022 *)

Formula

a(n) = 1 + A025047(n) - A025048(n) = Sum_{k=1..n} A059883(n,k). - Henry Bottomley, Feb 05 2001

Extensions

a(0)=1 prepended by Alois P. Heinz, Jan 20 2022
Name changed by Gus Wiseman, Jan 28 2022

A344614 Number of compositions of n with no adjacent triples (..., x, y, z, ...) where x < y < z or x > y > z.

Original entry on oeis.org

1, 1, 2, 4, 8, 16, 30, 58, 110, 209, 397, 753, 1429, 2711, 5143, 9757, 18511, 35117, 66621, 126389, 239781, 454897, 863010, 1637260, 3106138, 5892821, 11179603, 21209446, 40237641, 76337091, 144823431, 274752731, 521249018, 988891100, 1876081530, 3559220898, 6752400377
Offset: 0

Views

Author

Gus Wiseman, May 27 2021

Keywords

Comments

These compositions avoid the strict consecutive patterns (1,2,3) and (3,2,1), the weak version being A344604.

Examples

			The a(6) = 30 compositions are:
  (6)  (15)  (114)  (1113)  (11112)  (111111)
       (24)  (132)  (1122)  (11121)
       (33)  (141)  (1131)  (11211)
       (42)  (213)  (1212)  (12111)
       (51)  (222)  (1221)  (21111)
             (231)  (1311)
             (312)  (2112)
             (411)  (2121)
                    (2211)
                    (3111)
Missing are: (123), (321).
		

Crossrefs

A001250 counts alternating permutations.
A005649 counts anti-run patterns.
A025047 counts wiggly compositions (ascend: A025048, descend: A025049).
A106356 counts compositions by number of maximal anti-runs.
A114901 counts compositions where each part is adjacent to an equal part.
A325534 counts separable partitions.
A325535 counts inseparable partitions.
A344604 counts wiggly compositions with twins.
A344605 counts wiggly patterns with twins.
A344606 counts wiggly permutations of prime factors with twins.
Counting compositions by patterns:
- A003242 avoiding (1,1) adjacent.
- A011782 no conditions.
- A106351 avoiding (1,1) adjacent by sum and length.
- A128695 avoiding (1,1,1) adjacent.
- A128761 avoiding (1,2,3).
- A232432 avoiding (1,1,1).
- A335456 all patterns.
- A335457 all patterns adjacent.
- A335514 matching (1,2,3).
- A344604 weakly avoiding (1,2,3) and (3,2,1) adjacent.
- A344614 avoiding (1,2,3) and (3,2,1) adjacent.
- A344615 weakly avoiding (1,2,3) adjacent.

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],!MatchQ[#,{_,x_,y_,z_,_}/;xy>z]&]],{n,0,15}]

Extensions

More terms from Bert Dobbelaere, Jun 12 2021

A348615 Number of non-alternating permutations of {1...n}.

Original entry on oeis.org

0, 0, 0, 2, 14, 88, 598, 4496, 37550, 347008, 3527758, 39209216, 473596070, 6182284288, 86779569238, 1303866853376, 20884006863710, 355267697410048, 6397563946377118, 121586922638606336, 2432161265800164950, 51081039175603191808, 1123862030028821404198
Offset: 0

Views

Author

Gus Wiseman, Nov 03 2021

Keywords

Comments

A sequence is alternating if it is alternately strictly increasing and strictly decreasing, starting with either.
Also permutations of {1...n} matching the consecutive patterns (1,2,3) or (3,2,1). Matching only one of these gives A065429.

Examples

			The a(4) = 14 permutations:
  (1,2,3,4)  (3,1,2,4)
  (1,2,4,3)  (3,2,1,4)
  (1,3,4,2)  (3,4,2,1)
  (1,4,3,2)  (4,1,2,3)
  (2,1,3,4)  (4,2,1,3)
  (2,3,4,1)  (4,3,1,2)
  (2,4,3,1)  (4,3,2,1)
		

Crossrefs

The complement is counted by A001250, ranked by A333218.
The complementary version for compositions is A025047, ranked by A345167.
A directed version is A065429, complement A049774.
The version for compositions is A345192, ranked by A345168.
The version for ordered factorizations is A348613, complement A348610.
A345165 counts partitions w/o an alternating permutation, ranked by A345171.
A345170 counts partitions w/ an alternating permutation, ranked by A345172.
A348379 counts factorizations with an alternating permutation.
A348380 counts factorizations without an alternating permutation.

Programs

  • Maple
    b:= proc(u, o) option remember;
          `if`(u+o=0, 1, add(b(o-1+j, u-j), j=1..u))
        end:
    a:= n-> n!-`if`(n<2, 1, 2)*b(n, 0):
    seq(a(n), n=0..30);  # Alois P. Heinz, Nov 04 2021
  • Mathematica
    wigQ[y_]:=Or[Length[y]==0,Length[Split[y]] ==Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1];
    Table[Length[Select[Permutations[Range[n]],!wigQ[#]&]],{n,0,6}]
  • Python
    from itertools import accumulate, count, islice
    def A348615_gen(): # generator of terms
        yield from (0,0)
        blist, f = (0,2), 1
        for n in count(2):
            f *= n
            yield f - (blist := tuple(accumulate(reversed(blist),initial=0)))[-1]
    A348615_list = list(islice(A348615_gen(),40)) # Chai Wah Wu, Jun 09-11 2022

Formula

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

A177523 Number of permutations of 1..n avoiding adjacent step pattern up, up, up, up.

Original entry on oeis.org

1, 1, 2, 6, 24, 119, 709, 4928, 39144, 349776, 3472811, 37928331, 451891992, 5832672456, 81074690424, 1207441809209, 19181203110129, 323753459184738, 5785975294622694, 109149016813544376, 2167402030585724571, 45190632809497874161, 987099099863360190632
Offset: 0

Views

Author

R. H. Hardin, May 10 2010

Keywords

Comments

a(n) is the number of permutations of length n that avoid the consecutive pattern 12345 (or equivalently 54321).

Examples

			E.g.f.: A(x) = 1 + x + 2*x^2/2! + 6*x^3/3! + 24*x^4/4! + 119*x^5/5! + 709*x^6/6! +...
where A(x) = 1/(1 - x + x^5/5! - x^6/6! + x^10/10! - x^11/11! + x^15/15! - x^16/16! + x^20/20! +...).
		

Crossrefs

Column k=15 of A242784.

Programs

  • Mathematica
    Table[n!*SeriesCoefficient[1/(Sum[x^(5*k)/(5*k)!-x^(5*k+1)/(5*k+1)!,{k,0,n}]),{x,0,n}],{n,0,20}] (* Vaclav Kotesovec, Dec 11 2013 *)
    FullSimplify[CoefficientList[Series[10*E^((1+Sqrt[5])*x/4) / ((5+Sqrt[5]) * Cos[Sqrt[(5-Sqrt[5])/2]*x/2] + (5-Sqrt[5]) * E^(Sqrt[5]*x/2) * Cos[Sqrt[(5+Sqrt[5])/2]*x/2] - Sqrt[2*(5-Sqrt[5])] * Sin[Sqrt[(5-Sqrt[5])/2]*x/2] - Sqrt[2*(5+Sqrt[5])] * E^(Sqrt[5]*x/2) * Sin[Sqrt[(5+Sqrt[5])/2]*x/2]),{x,0,20}],x]*Range[0,20]!] (* Vaclav Kotesovec, Aug 29 2014 *)
  • PARI
    {a(n)=n!*polcoeff(1/sum(m=0, n\5+1, x^(5*m)/(5*m)!-x^(5*m+1)/(5*m+1)!+x^2*O(x^n)), n)}

Formula

E.g.f.: 1/( Sum_{n>=0} x^(5*n)/(5*n)! - x^(5*n+1)/(5*n+1)! ).
a(n)/n! ~ c * (1/r)^n, where r = 1.007187547786015395418998654... is the root of the equation Sum_{n>=0} (r^(5*n)/(5*n)! - r^(5*n+1)/(5*n+1)!) = 0, c = 1.02806793756750152.... - Vaclav Kotesovec, Dec 11 2013
Equivalently, r = 1.00718754778601539541899865400272701484... is the root of the equation (5+sqrt(5)) * cos(sqrt((5-sqrt(5))/2)*r/2) + (5-sqrt(5)) * exp(sqrt(5)*r/2) * cos(sqrt((5+sqrt(5))/2)*r/2) - sqrt(2*(5-sqrt(5))) * sin(sqrt((5-sqrt(5))/2)*r/2) - sqrt(2*(5+sqrt(5))) * exp(sqrt(5)*r/2) * sin(sqrt((5+sqrt(5))/2)*r/2) = 0. - Vaclav Kotesovec, Aug 29 2014
E.g.f.: 10*exp((1+sqrt(5))*x/4) / ((5+sqrt(5)) * cos(sqrt((5-sqrt(5))/2)*x/2) + (5-sqrt(5)) * exp(sqrt(5)*x/2) * cos(sqrt((5+sqrt(5))/2)*x/2) - sqrt(2*(5-sqrt(5))) * sin(sqrt((5-sqrt(5))/2)*x/2) - sqrt(2*(5+sqrt(5))) * exp(sqrt(5)*x/2) * sin(sqrt((5+sqrt(5))/2)*x/2)). - Vaclav Kotesovec, Aug 29 2014
In closed form, c = 5*exp((1+sqrt(5))*r/4) / (r*((5 + sqrt(5)) * cos(sqrt((5 - sqrt(5))/2)*r/2) + (5 - sqrt(5)) * exp(sqrt(5)*r/2) * cos(sqrt((5 + sqrt(5))/2)*r/2))) = 1.0280679375675015201596831656779442465978511664638... . Vaclav Kotesovec, Feb 01 2015

Extensions

More terms from Ray Chandler, Dec 06 2011
a(0)=1 prepended by Alois P. Heinz, Jan 13 2015

A344615 Number of compositions of n with no adjacent triples (..., x, y, z, ...) where x <= y <= z.

Original entry on oeis.org

1, 1, 2, 3, 6, 10, 17, 29, 50, 84, 143, 241, 408, 688, 1162, 1959, 3305, 5571, 9393, 15832, 26688, 44980, 75812, 127769, 215338, 362911, 611620, 1030758, 1737131, 2927556, 4933760, 8314754, 14012668, 23615198, 39798098, 67070686, 113032453, 190490542, 321028554
Offset: 0

Views

Author

Gus Wiseman, May 27 2021

Keywords

Comments

These compositions avoid the weak consecutive pattern (1,2,3), the strict version being A128761.

Examples

			The a(1) = 1 through a(6) = 17 compositions:
  (1)  (2)    (3)    (4)      (5)        (6)
       (1,1)  (1,2)  (1,3)    (1,4)      (1,5)
              (2,1)  (2,2)    (2,3)      (2,4)
                     (3,1)    (3,2)      (3,3)
                     (1,2,1)  (4,1)      (4,2)
                     (2,1,1)  (1,3,1)    (5,1)
                              (2,1,2)    (1,3,2)
                              (2,2,1)    (1,4,1)
                              (3,1,1)    (2,1,3)
                              (1,2,1,1)  (2,3,1)
                                         (3,1,2)
                                         (3,2,1)
                                         (4,1,1)
                                         (1,2,1,2)
                                         (1,3,1,1)
                                         (2,1,2,1)
                                         (2,2,1,1)
		

Crossrefs

The case of permutations is A049774.
The strict non-adjacent version is A102726.
The case of permutations of prime indices is A344652.
A001250 counts alternating permutations.
A005649 counts anti-run patterns.
A106356 counts compositions by number of maximal anti-runs.
A114901 counts compositions where each part is adjacent to an equal part.
A344604 counts wiggly compositions with twins.
A344605 counts wiggly patterns with twins.
A344606 counts wiggly permutations of prime factors with twins.
Counting compositions by patterns:
- A003242 avoiding (1,1) adjacent.
- A011782 no conditions.
- A106351 avoiding (1,1) adjacent by sum and length.
- A128695 avoiding (1,1,1) adjacent.
- A128761 avoiding (1,2,3).
- A232432 avoiding (1,1,1).
- A335456 all patterns.
- A335457 all patterns adjacent.
- A335514 matching (1,2,3).
- A344604 weakly avoiding (1,2,3) and (3,2,1) adjacent.
- A344614 avoiding (1,2,3) and (3,2,1) adjacent.
- A344615 weakly avoiding (1,2,3) adjacent.

Programs

  • Mathematica
    Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],!MatchQ[#,{_,x_,y_,z_,_}/;x<=y<=z]&]],{n,0,15}]

Extensions

More terms from Bert Dobbelaere, Jun 12 2021

A344605 Number of alternating patterns of length n, including pairs (x,x).

Original entry on oeis.org

1, 1, 3, 6, 22, 102, 562, 3618, 26586, 219798, 2018686, 20393790, 224750298, 2683250082, 34498833434, 475237879950, 6983085189454, 109021986683046, 1802213242949602, 31447143854808378, 577609702827987882, 11139837273501641502, 225075546284489412854
Offset: 0

Views

Author

Gus Wiseman, May 27 2021

Keywords

Comments

We define a pattern to be a finite sequence covering an initial interval of positive integers. Patterns are counted by A000670. A sequence is alternating (cf. A025047) including pairs (x,x) if there are no adjacent triples (..., x, y, z, ...) where x <= y <= z or x >= y >= z. These sequences avoid the weak consecutive patterns (1,2,3) and (3,2,1).
An alternating pattern of length > 2 is necessarily an anti-run (A005649).
The version without pairs (x,x) is identical to this sequence except a(2) = 2 instead of 3.

Examples

			The a(0) = 1 through a(4) = 22 patterns:
  ()  (1)  (1,1)  (1,2,1)  (1,2,1,2)
           (1,2)  (1,3,2)  (1,2,1,3)
           (2,1)  (2,1,2)  (1,3,1,2)
                  (2,1,3)  (1,3,2,3)
                  (2,3,1)  (1,3,2,4)
                  (3,1,2)  (1,4,2,3)
                           (2,1,2,1)
                           (2,1,3,1)
                           (2,1,3,2)
                           (2,1,4,3)
                           (2,3,1,2)
                           (2,3,1,3)
                           (2,3,1,4)
                           (2,4,1,3)
                           (3,1,2,1)
                           (3,1,3,2)
                           (3,1,4,2)
                           (3,2,3,1)
                           (3,2,4,1)
                           (3,4,1,2)
                           (4,1,3,2)
                           (4,2,3,1)
		

Crossrefs

The version for permutations is A001250.
The version for compositions is A344604.
The version for permutations of prime indices is A344606.
A000670 counts patterns (ranked by A333217).
A003242 counts anti-run compositions.
A005649 counts anti-run patterns.
A019536 counts necklace patterns.
A025047 counts alternating or wiggly compositions, complement A345192.
A226316 counts patterns avoiding (1,2,3) (weakly: A052709).
A335515 counts patterns matching (1,2,3).

Programs

  • Mathematica
    allnorm[n_]:=If[n<=0,{{}},Function[s,Array[Count[s,y_/;y<=#]+1&,n]]/@Subsets[Range[n-1]+1]];
    Table[Length[Select[Join@@Permutations/@allnorm[n],!MatchQ[#,{_,x_,y_,z_,_}/;x<=y<=z||x>=y>=z]&]],{n,0,6}]

Extensions

a(10) and beyond from Martin Ehrenstein, Jun 10 2021
Showing 1-10 of 57 results. Next