A349052 Number of weakly alternating compositions of n.
1, 1, 2, 4, 8, 16, 28, 52, 91, 161, 280, 491, 850, 1483, 2573, 4469, 7757, 13472, 23378, 40586, 70438, 122267, 212210, 368336, 639296, 1109620, 1925916, 3342755, 5801880, 10070133, 17478330, 30336518, 52653939, 91389518, 158621355, 275313226, 477850887, 829388075
Offset: 0
Keywords
Examples
The a(5) = 16 compositions: (1,1,1,1,1) (1,1,1,2) (1,1,3) (1,4) (5) (1,1,2,1) (1,2,2) (2,3) (1,2,1,1) (1,3,1) (3,2) (2,1,1,1) (2,1,2) (4,1) (2,2,1) (3,1,1) The a(6) = 28 compositions: (111111) (11112) (1113) (114) (15) (6) (11121) (1122) (132) (24) (11211) (1131) (141) (33) (12111) (1212) (213) (42) (21111) (1311) (222) (51) (2121) (231) (2211) (312) (3111) (411)
Links
- Andrew Howroyd, Table of n, a(n) for n = 0..1000 (Terms 0..55 from Martin Ehrenstein)
Crossrefs
Programs
-
Mathematica
whkQ[y_]:=And@@Table[If[EvenQ[m],y[[m]]<=y[[m+1]],y[[m]]>=y[[m+1]]],{m,1,Length[y]-1}]; Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],whkQ[#]||whkQ[-#]&]],{n,0,10}]
-
PARI
C(n,f)={my(M=matrix(n,n,j,k,k>=j), s=M[,n]); for(b=1, n, f=!f; M=matrix(n,n,j,k, if(k
1,M[j-k,k-1]) ))); for(k=2, n, M[,k]+=M[,k-1]); s+=M[,n]); s~} seq(n) = concat([1], C(n,0) + C(n,1) - vector(n,j,numdiv(j))) \\ Andrew Howroyd, Jan 31 2024
Extensions
a(21)-a(37) from Martin Ehrenstein, Jan 08 2022
Comments