%I #24 Dec 23 2020 08:45:03
%S 1,1,1,1,2,0,1,3,0,0,1,4,4,0,0,1,5,10,10,10,10,1,6,18,36,60,84,60,1,7,
%T 28,84,210,434,630,462,1,8,40,160,544,1552,3440,5168,3920,1,9,54,270,
%U 1170,4338,13158,30366,47178,36954,1,10,70,420,2220,10220,39780,125220,298060,476220,382740
%N Triangle read by rows: T(n,k) is the number of permutations of k elements from [1..n] where adjacent values cannot be consecutive modulo n.
%C In a convex n-gon, the number of paths using k-1 diagonals and k non-repeated vertices.
%F T(n,k) = n*(A338526(n-1,k-1)-S(n-1,k-1)) for k>0 except T(2,2)=0, T(n,0)=1, where S(n,k) = 2*A338526(n-1,k-1)-S(n-1,k-1) for k>0, S(n,0)=0.
%e n\k 0 1 2 3 4 5 6 7 8
%e 0 1
%e 1 1 1
%e 2 1 2 0
%e 3 1 3 0 0
%e 4 1 4 4 0 0
%e 5 1 5 10 10 10 10
%e 6 1 6 18 36 60 84 60
%e 7 1 7 28 84 210 434 630 462
%e 8 1 8 40 160 544 1552 3440 5168 3920
%o (PARI) isokd(d, n) = my(x=abs(d)); (x==1) || (x==(n-1));
%o isok(s, p, n) = {my(w = vector(#s, k, s[p[k]])); for (i=1, #s-1, if (isokd(w[i+1] - w[i], n) == 1, return (0))); return (1);}
%o T(n, k) = {my(nb = 0); forsubset([n, k], s, for(i=1, k!, if (isok(s, numtoperm(k, i), n), nb++););); nb;} \\ _Michel Marcus_, Nov 21 2020
%Y Right diagonal is A002493.
%Y Cf. A011973, A034807, A338526, A338849, A000166.
%K nonn,tabl
%O 0,5
%A _Xiangyu Chen_, Nov 11 2020
|