A277256
Multi-table menage numbers T(n,k) for n,k >= 1 equals the number of ways to seat the gentlemen from n*k married couples at n round tables with 2*k seats each such that (i) the gender of persons alternates around each table; and (ii) spouses do not sit next to each other; provided that the ladies are already properly seated (i.e., no two ladies sit next to each other).
Original entry on oeis.org
0, 1, 0, 2, 4, 1, 9, 80, 82, 2, 44, 4752, 43390, 4740, 13, 265, 440192, 59216968, 59216648, 439794, 80, 1854, 59245120, 164806652728, 2649391488016, 164806435822, 59216644, 579, 14833, 10930514688, 817056761525488, 312400218967336992, 312400218673012936, 817056406224656, 10927434466, 4738
Offset: 1
Table T(n,k):
n=1: 0, 0, 1, 2, ...
n=2: 1, 4, 82, 4740, ...
n=3: 2, 80, 43390, 59216648, ...
n=4: 9, 4752, 59216968, 2649391488016, ...
n=5: 44, 440192, 164806652728, 312400218967336992, ...
...
-
{ A277256(n,k) = my(m,s,g); m=n*k; s=sqrt(1+4*x+O(x^(m+1))); g=if(k==1,1+z,((1-s)/2)^(2*k)+((1+s)/2)^(2*k))^n; sum(j=0,m,(-1)^j*polcoeff(g,j)*(m-j)!); }
A354408
Triangle read by rows of generalized ménage numbers: T(n,k) is the number of permutations pi in S_n such that pi(i) != i and pi(i) != i+k (mod n) for all i; n, 1 <= k < n.
Original entry on oeis.org
0, 1, 1, 2, 4, 2, 13, 13, 13, 13, 80, 82, 80, 82, 80, 579, 579, 579, 579, 579, 579, 4738, 4740, 4738, 4752, 4738, 4740, 4738, 43387, 43387, 43390, 43387, 43387, 43390, 43387, 43387, 439792, 439794, 439792, 439794, 440192, 439794, 439792, 439794, 439792
Offset: 2
Triangle begins:
n\k| 1 2 3 4 5 6 7 8
-----+------------------------------------------------
2 | 0
3 | 1 1
4 | 2 4 2
5 | 13 13 13 13
6 | 80 82 80 82 80
7 | 579 579 579 579 579 579
8 | 4738 4740 4738 4752 4738 4740 4738
9 | 43387 43387 43390 43387 43387 43390 43387 43387
...
-
from sympy import Matrix
def A354408(n,k):
return Matrix(n,n,lambda i,j:int(i!=j and i!=(j+k)%n)).per() # Pontus von Brömssen, May 31 2022
-
# This version, based on the formula in A277256, is much faster than the version using permanents, at least for large n.
from sympy import factorial,gcd,sqrt
from sympy.abc import z
def A354408(n,k):
k=gcd(n,k)
F=((1-sqrt(1+4*z))/2)**(2*(n//k))+((1+sqrt(1+4*z))/2)**(2*(n//k))
p=(F**k).series(z,0,n+1)
return sum((-1)**j*factorial(n-j)*p.coeff(z,j) for j in range(n+1)) # Pontus von Brömssen, Jun 02 2022
A354152
a(n) is the number of permutations pi in S_n such that pi(i) - i != 1 (mod n) and pi(i) - i != -1 (mod n) for all i.
Original entry on oeis.org
1, 0, 1, 1, 4, 13, 82, 579, 4740, 43387, 439794, 4890741, 59216644, 775596313, 10927434466, 164806435783, 2649391469060, 45226435601207, 817056406224418, 15574618910994665, 312400218671253764, 6577618644576902053, 145051250421230224306, 3343382818203784146955
Offset: 0
For n = 5, the a(5) = 13 permutations are 12345, 12543, 14325, 14523, 15342, 32145, 34125, 34512, 35142, 42315, 42513, 45123, and 45312.
The first letter is never 2 or 5, the second letter is never 1 or 3, the third letter is never 2 or 4, the fourth letter is never 3 or 5 and the fifth letter is never 1 or 4.
Showing 1-3 of 3 results.
Comments