A322145
Number of permutations of 9 copies of 1..n with no element equal to another within a distance of 1.
Original entry on oeis.org
1, 0, 2, 17236524, 2511603532825176, 2829059722872229922701920, 17498057808683351584656839871450000, 459422439054082909311010463927575656038701920, 42176005899746902650961357272521722186133207293858938240
Offset: 0
A322146
Number of permutations of 10 copies of 1..n with no element equal to another within a distance of 1.
Original entry on oeis.org
1, 0, 2, 124948668, 174702663548149248, 2360719028641481267959955040, 211490077066069537208795610578715159120, 94446414948214202156311984061437135600678877848560
Offset: 0
A377586
Numbers of directed Hamiltonian paths in the complete 4-partite graph K_{n,n,n,n}.
Original entry on oeis.org
24, 13824, 53529984, 751480602624, 27917203599360000, 2267561150913576960000, 354252505303682314076160000, 97087054992658680467800719360000, 43551509948777170973522371396239360000, 30293653795894300342540281328749772800000000
Offset: 1
-
Table[n!^4 * SeriesCoefficient[1/(1 - Sum[x[i]/(1 + x[i]), {i, 1, 4}]), Sequence @@ Table[{x[i], 0, n}, {i, 1, 4}]], {n, 1, 10}]
-
from math import factorial as fact, comb
from itertools import combinations_with_replacement
def a(n):
# Using modified formula for counting sequences found in Eifler et al.
result = 0
fn = fact(n)
for i, j, k in combinations_with_replacement(range(1, n+1), 3):
patterns = [(3,0,0)] if i == j == k else \
[(2,0,1)] if i == j != k else \
[(1,2,0)] if i != j == k else [(1,1,1)]
for a, b, c in patterns:
s = a*i + b*j + c*k
num = fact(3)
den = fact(a) * fact(b) * fact(c)
if a:
for _ in range(a): num, den = num * comb(n-1, i-1), den * fact(i)
if b:
for _ in range(b): num, den = num * comb(n-1, j-1), den * fact(j)
if c:
for _ in range(c): num, den = num * comb(n-1, k-1), den * fact(k)
num *= comb(s + 1, n) * fact(s)
result += (1 if (3*n - s) % 2 == 0 else -1) * (num // den)
for _ in range(4): result *= fn
return result
print([a(n) for n in range(1,11)]) # Zlatko Damijanic, Nov 18 2024