Finding the $N^{th}$ derivative of $(1 + x + x^2 + ... + x^A)^K$ Given a polynomial $P(x) = (1 + x + x^2 + ... + x^A)^K$, I want to find $P^{n}(0)$, that is, the value at $x=0$ of the $N^{th}$ derivative of $P(x)$.
($A$ and $K$ are natural numbers).
I want to use this to find the coefficient of $x^N$.
I can write some code to compute it, so I am looking for a fast method to calculate this.
Should I split $P(x)$ into $(1 - x^{A+1})^K.(1-x)^K$ first and then find the derivative? What would be the best way to go about it?
 A: The coefficient of $x^n$ in the product $(1 + x + x^2 + ... + x^A)^K$ is the number of ways in which $K$ elements (i.e. a $K$-tuple of elements) may be selected from $\{0,1,2,\dots,A\}$ so that they add up to $n$.  For example: if $A = 10$, $k = 3$, $n=2$, we have
$$
2 = 0+1+1 = 1+0+1 = 1+1+0\\
= 2+0+0=0+2+0=0+0+2
$$
so, the coefficient of $x^2$ would be $c_2 = 6$.  
Whenever $n \leq A$, it suffices to use the stars and bars formula so that
$$
c_n = \binom{n + k - 1}{k-1}
$$
If $n > A$, we need to discount any $K$-tuples that use numbers larger than $A$, so this formula no longer applies.  We can certainly make some code to answer this question, though.  Here's a neat recursive method:
define c(K,N,A)

if K = 1
    return 1
if N < 0
    return 0
else
    sum = 0
    for i = 0,...,A
        sum = sum + c(K-1,N-i,A)
    return sum

Or, I suppose we could always use our formula as a base case:
define c(K,N,A)

if K = 1
    return 1
if N <= A
    return choose(N+K-1,K-1)
else
    sum = 0
    for i = 0,...,N
        sum = sum + c(K-1,N-i,A)
    return sum

A: The coefficient of $x^n$ is $$\sum_{k_0+k_1+k_2+\cdots k_A=K\\k_1+2k_2+\cdots Ak_A=n}\binom n{k_0,k_1,\cdots k_A}.$$
A: This is a dynamic programming problem with solution $O(n^2k)$. The following works even if $n > A$ and is similar to @Omnomnomnom's recursive solution.
Base Case: For $(\sum_{i=0}^a x^i)^0$, the coefficient of $x^j$ for $j=0$ is $1$ and $0$ for $0 < j \leq N$.
Induction: Now, let's say we know $(\sum_{i=0}^a x^i)^k$ is $\sum_{i=0}^{ka} c_ix^i$ for some real numbers $c_i$. We just want to find $x^n$, so I will ignore all terms with $i > n$, so let's rewrite this as $\sum_{i=0}^n c_ix^i$. Now, we want to find $(\sum_{i=0}^a x^i)^{k+1}$, which is:
$$\left(\sum_{i=0}^a x^i\right)^k\left(\sum_{i=0}^a x^i\right)=\left(\sum_{i=0}^n c_ix^i\right)\left(\sum_{i=0}^a x^i\right)$$
Now, the coefficient of $x^j$ is made from $c_ix^i\cdot x^{j-i}$ where $0 \leq i \leq j$ and $0 \leq j-i \leq a$. Do this for all $0 \leq j \leq n$ and then repeat the process until $k=K$.
Here's the  Python code for this:
# Set these to whatever you want
N = 2
K = 3
A = 5

coeffs = []
# Case k=0 -> All coeffs are 0 except for j=0
coeffs.append([])
coeffs[0].append(1)
for j in range(1, N+1): coeffs[0].append(0)
# Induction case:
for k in range(K):
    coeffs.append([])
    # Get the coefficient of x^j
    for j in range(N+1):
        coeffs[k+1].append(0)
        # Sum coefficients of x^i for 0 <= i <= j and 0 <= j-i <= a
        for i in range(j+1):
            if j-i <= A: coeffs[k+1][j] += coeffs[k][i]
        # The last print statement from this program will give you the coefficient of x^N for the power k=K
        print(k+1, j, coeffs[k+1][j])

