<s>[INST] What's the ammount of solutions to the Equation $A+B+C+D=24$ with restrictions on $A$ and $B$ As the title says, I have the the following equation:
$A+B+C+D=24$
$2\leq A\leq 5$ and $4\leq B\leq 7$
And i need to find the number of possible solutions. $A,B,C,D\geq 0$, They are integers.
I'm not sure if my solution is right, What i did is:
I've made a new equation stating $A_1=A-2$ and $B_1=B-4,$ So i get:
$A_1+B_1+C+D=30.$
So my restrictions now are $0\leq B \leq 3$, Marking $A_1+B_1=S, S=[0,6],$ Means:
$C+D=30-S $ And the number of possibilities for that one is $31-S$.
So now i need to do the sum: $\sum (31-S)$ from $S=0$ to  $ S=6$ and multiply it by $3^2 \;$ [Which represents the different combinations of $A$ and $B$] so that equals to: $1774.$
Did I do something wrong or it seems fine?
 [/INST] By using ordinary generating function:
let $A=g_1(x)=(x^2+x^3+x^4+x^5)=x^2(1+x+x^2+x^3)$
let $B=g_2(x)=(x^4+x^5+x^6+x^7)=x^4(1+x+x^2+x^3)$
let $C=g_3(x)=(1+x+x^2+\dots\dots)$
let $D=g_4(x)=(1+x+x^2+\dots\dots)$
Then $G(x)=g_1(x)g_2(x)g_3(x)g_4(x)=x^6\frac{(1-x^4)^2}{(1-x)^2}\frac{1}{(1-x)^2}=x^6\frac{1-2x^4+x^8}{(1-x)^4}$, now you need to find $[x^{18}]$ in $\frac{1-2x^4+x^8}{(1-x)^4}$, then you get
$$\binom{18+4-1}{4-1}-2\binom{14+4-1}{4-1}+\binom{10+4-1}{4-1}=256$$
</s>