I am trying to construct a way to make a function for the following recurrence relation. $$ Q(N,L) = \int_{0}^{L-(N-1)a} Q(N-1, L-a-z) dz $$, with the initial condition $Q(2,L) = \frac{1}{2} (a-L)^2$ for positive real numbers $a$ and $L$.
Since it involves recurrence relation, I tried to use a basic memoization trick below.
Q[n_, L_] := Q[n, L] =
Integrate[ Q[n - 1, L - a - z] , { z, 0, L - (n - 1) a}]
Q[2, L_] = 1/2 (a - L)^2
However, I found that this is not correct approach since the memoized $Q(k, L)$'s are not functions $L$ but some specific values like $Q(k, L - a-z)$. Even worse, this approach does not yield correct results. For example, I got $Q(4,L) = \frac{1}{12} (L-3 a)^4$ instead of correct value $Q(4,L) = \frac{1}{24} (L-3 a)^4$.
What is the correct way to achieve the desired behavior?
EDIT: As pointed out in the comment, this expression even does not yield a correct solution without the memoization parts. Therefore the question should be "What is the correct expression for the equation?". I would be more interested if the solution is somehow memoized.