I am trying to find an equation for finding the coefficient of the $k$th term of the expansion of $\left(\frac{x^n - 1}{x - 1}\right)^m$ for any $n$, $m$, and $k$.
So, far I've managed to find A277950 the terms for $m = 5$. I however have not been able to figure out what $k$ is in their formula for the sequence, and I can't find a way to generalize it for $m \neq 5$.
I have similarly written a python program to find the coefficients, which works by looping through the integers in $[1, n]$, $m$ times and then counting the number of times each number appears. Printing the number of time each number appears in order yields the coefficients of the expansion. I have no idea why this is working, but for every set of numbers I've tried it has worked correctly.
It is convenient to use the coefficient of operator $[x^k]$ to denote the coefficient of $x^k$ in a series. This way we can write e.g. \begin{align*} [x^k](1+x)^m=\binom{m}{k} \end{align*}
Comment:
In (1) we apply the binomial series expansion with $\alpha=-m$.
In (2) we expand the binomial $(1-x)^m$ and use the binomial identity
\begin{align*} \binom{-p}{q}=\binom{p+q-1}{q}(-1)^q \end{align*}
In (3) we use the linearity of the coefficient of operator and apply the rule $$[x^{p-q}]A(x)=[x^p]x^qA(x)$$ We also set the upper limit of the series to $k$ since the exponent of $x^{k-j}$ is non-negative.
In (4) we exchange the order of summation of the outer sum by replacing $j\rightarrow k-j$.
In (5) we select multiples of $n$ of the index $j$ since we have multiples of $n$ in the exponent $x^{nl}$ in the inner sum.
In (6) we select the coefficient of $[x^{nj}]$ in the inner sum by setting $l=j$.