A rather straightforward combinatorial question:
Given numbers $X, q, n$ such that $0 \leq X \leq n(q-1)$, what are the total number of ways to express $X$ as sum of $n$ numbers, where each summand is between $0$ and $q-1$ and the order does matter (e.g. $1+2$ and $2+1$ are considered different)?
I'd assume that there is an established formula for this but I couldn't find it via Google. If someone can give me a pointer to the result it would be much appreciated.
Thanks!
You can form a recurrence. Add $1$ to all the summands to get rid of the zeros. Now we want the number of compositions of $X+n$ into $n$ parts of maximum size $q$. Let $N(X+n,n)$ be the desired number of compositions of $X+n$ into $n$ parts of size at most $q$. Then $$N(i,n)=\begin {cases} 0 & i \lt n\\ 1& i=n\\ \sum_{j=1}^q N(i-j,n-1) & i \gt n\end {cases} $$