A325589 Number of compositions of n whose circular differences are all 1 or -1.
0, 0, 2, 0, 2, 2, 2, 4, 4, 2, 8, 6, 8, 10, 12, 16, 18, 20, 28, 34, 42, 48, 62, 78, 92, 112, 146, 174, 216, 264, 326, 412, 500, 614, 770, 944, 1166, 1444, 1784, 2214, 2730, 3366, 4182, 5164, 6386, 7898, 9770, 12098, 14950, 18488, 22894, 28312, 35020, 43330, 53606
Offset: 1
Keywords
Examples
The a(3) = 2 through a(11) = 8 compositions (empty columns not shown): (12) (23) (1212) (34) (1232) (45) (2323) (56) (21) (32) (2121) (43) (2123) (54) (3232) (65) (2321) (121212) (121232) (3212) (212121) (123212) (212123) (212321) (232121) (321212)
Links
- Andrew Howroyd, Table of n, a(n) for n = 1..200
Programs
-
Mathematica
Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],SameQ[1,##]&@@Abs[Differences[Append[#,First[#]]]]&]],{n,15}]
-
PARI
step(R,n,s)={matrix(n, n, i, j, if(i>j, if(j>s, R[i-j, j-s]) + if(j+s<=n, R[i-j, j+s])) )} a(n)={sum(k=1, n, my(R=matrix(n,n,i,j,i==j&&abs(i-k)==1), t=0); while(R, R=step(R,n,1); t+=R[n,k]); t)} \\ Andrew Howroyd, Aug 23 2019
Extensions
Terms a(26) and beyond from Andrew Howroyd, Aug 23 2019
Comments