OFFSET
1,1
LINKS
Zlatko Damijanic, Table of n, a(n) for n = 1..117
L. Q. Eifler, K. B. Reid Jr., and D. P. Roselle, Sequences with adjacent elements unequal, Aequationes Mathematicae 6 (2-3), 1971; see also.
MATHEMATICA
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}]
PROG
(Python)
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
CROSSREFS
KEYWORD
nonn
AUTHOR
Zlatko Damijanic, Nov 02 2024
STATUS
approved