login
Number of compositions of n avoiding the pattern 111.
14

%I #35 Nov 20 2023 10:51:19

%S 1,1,2,3,7,11,21,34,59,114,178,284,522,823,1352,2133,3739,5807,9063,

%T 14074,23639,36006,56914,87296,131142,214933,324644,487659,739291,

%U 1108457,1724673,2558386,3879335,5772348,8471344,12413666,19109304,27886339,40816496

%N Number of compositions of n avoiding the pattern 111.

%C Number of compositions of n into parts with multiplicity <= 2.

%H Alois P. Heinz, <a href="/A232432/b232432.txt">Table of n, a(n) for n = 0..1000</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Permutation_pattern">Permutation pattern</a>

%H Gus Wiseman, <a href="/A102726/a102726.txt">Sequences counting and ranking compositions by the patterns they match or avoid.</a>

%e a(4) = 7: [4], [3,1], [2,2], [1,3], [2,1,1], [1,2,1], [1,1,2].

%e a(5) = 11: [5], [4,1], [3,2], [2,3], [1,4], [3,1,1], [2,2,1], [1,3,1], [2,1,2], [1,2,2], [1,1,3].

%e a(6) = 21: [6], [4,2], [3,3], [5,1], [2,4], [1,5], [2,1,3], [1,2,3], [1,1,4], [4,1,1], [3,2,1], [2,3,1], [1,4,1], [3,1,2], [1,3,2], [1,2,2,1], [2,1,1,2], [1,2,1,2], [1,1,2,2], [2,2,1,1], [2,1,2,1].

%p b:= proc(n, i, p) option remember; `if`(n=0, p!, `if`(i<1, 0,

%p add(b(n-i*j, i-1, p+j)/j!, j=0..min(n/i, 2))))

%p end:

%p a:= n-> b(n$2, 0):

%p seq(a(n), n=0..50);

%t f[list_]:=Apply[And,Table[Count[list,i]<3,{i,1,Max[list]}]];

%t g[list_]:=Length[list]!/Apply[Times,Table[Count[list,i]!,{i,1,Max[list]}]];

%t a[n_] := If[n == 0, 1, Total[Map[g, Select[IntegerPartitions[n], f]]]];

%t Table[a[n], {n, 0, 35}] (* _Geoffrey Critzer_, Nov 25 2013, updated by _Jean-François Alcover_, Nov 20 2023 *)

%Y Cf. A000726 (partitions avoiding 111), A032020 (pattern 11), A128695 (adjacent pattern 111).

%Y Column k=2 of A243081.

%Y The case of partitions is ranked by A004709.

%Y The version for patterns is A080599.

%Y (1,1,1,1)-avoiding partitions are counted by A232464.

%Y The (1,1,1)-matching version is A335455.

%Y Patterns matched by compositions are counted by A335456.

%Y The version for prime indices is A335511.

%Y (1,1,1)-avoiding compositions are ranked by A335513.

%Y Cf. A011782, A006918, A102726, A106356, A238279, A333755.

%K nonn

%O 0,3

%A _Alois P. Heinz_, Nov 23 2013