I've been trying to derive this formula for quite some time now with little progress.
I've seen concepts such as Pascal's pyramids and Pascal's simplices mentioned throughout my research; however, I doubt their significance to the formula.
The most promising outlet I've seen are the coefficients that come from the expansion of $(1 + x^2 + x^3 +\dots + x^{r - 1})^n$ [for various values of $r$ and all values of $n$].
I've seen somewhat similar questions posted on Math SE before, but I'm struggling to find an answer that provides an accurate formula as well as a general breakdown of how it was achieved.
If someone could help, that would be great!
Searching this sequence on the OEIS gives A027907 which are the trinomial coefficients; these are the coefficients in the expansion of $(1 + x + x^2)^4$. They can be expressed in terms of multinomial coefficients (which in this case can be thought of as Pascal's pyramid if you want to think of them that way) by the multinomial theorem; doing this gives that the $i^{th}$ term is
$$\sum_{a+2b=i} \frac{4!}{a! b! (4-a-b)!}.$$
For example, the $i = 2$ term is $\frac{4!}{0! 1! 3!} + \frac{4!}{2! 0! 2!} = 4 + 6 = 10$.
(There is a slightly unfortunate collision of terminology here; the trinomial coefficients are not the $3$-variable special case of the multinomial coefficients. Unfortunately I don't know a better name for these numbers.)