Write a generating function for the number of ways to make a basket of $n$ marbles, if you need to use at least one orange marble , an even number of yellow marbles, at most 2 green marbles, and any number of red marbles.
Because the question is asking for a generating function, it seems to me like it may be possible to create a recurrence relation and then solve the relation to create the generating function. However, I'm not sure how to go about finding that relation. The fact that we need an even number of yellow marbles is giving me trouble.
For instance, if we ignore that we need an even number of yellow marbles, we obtain:
(1) $n_o+n_y+n_g+n_r=n$ where $n_0>0$ and $n_g<3$ so what follows is
(2) $n'_o+n_y+n_g+n_r=n-1$ where $n_g<3$. Then we can solve the number of solutions to this equation minus the number of solutions where the number of green marbles is greater than or equal to 3 and take the difference between the two.
Where the number of solutions to (2)(ignoring the bounds on green marbles) is $n-1+4-1 \choose 3$=$n+2 \choose 3$
Any ideas on how to calculate the number of ways, say $f_n$, through a recurrence relation?
It’s easiest simply to write down the generating function. You want the coefficient of $x^n$ to be the number of ways to decompose $n$ as
$$n=n_o+n_y+n_g+n_r\;,\tag{1}$$
where $n_o\ge 1$, $n_g\le 2$, and $n_y$ is even. You can arrange this by noting that $n_o$ must be an exponent in the sum
$$x^1+x^2+x^3+\ldots\;,$$
$n_g$ must be an exponent in the sum
$$x^0+x^1+x^2\;,$$
$n_y$ must be an exponent in the sum
$$x^0+x^2+x^4+\ldots\;,$$
and $n_r$ must be an exponent in the sum
$$x^0+x^1+x^2+x^3+\ldots\;.$$
Thus, if you multiply these four expressions together, you’ll get one $x^n$ term for each solution to $(1)$ meeting the stated requirements. Your generating function is therefore
$$\left(\sum_{k\ge 1}x^k\right)(1+x+x^2)\left(\sum_{k\ge 0}x^{2k}\right)\left(\sum_{k\ge 0}x^k\right)\;.\tag{2}$$
It’s straightforward to convert each of the three infinite series in $(2)$ into the corresponding function, and all that then remains is to multiply them together along with the quadratic $1+x+x^2$.