I know that for $1\leq x_i\leq p$ the answer will be the coefficient of $x^n$ in $(x + x^2 + x^3 + ... + x^p)^k$. But what will be the answer for the constraint $0 \leq x_i \leq p?$
Also, how can I generate a definite formula or recurrence relation to program it? It will be difficult to calculate the answer by summing up the GP series and then calculating the coefficients using series expansion.
Thank you!
You can use your generating function approach just putting an $x^0=1$ term in and getting $(1+x + x^2 + x^3 + ... + x^p)^k$