<s>[INST] Generating function to find the number of ways to put marbles in a basket 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?
 [/INST] Completing Brian Scott's answer, you are after the coefficient of $z^n$ in the following. This yields to partial fractions and using geometric series and (generalized) binomial theorem:
$\begin{align}
  [z^n] \left( \sum_{k \ge 1} z^k \right)
          \cdot &\left( 1 + z + z^2 \right)
          \cdot \left( \sum_{k \ge 0} z^{2 k} \right)
          \cdot \left( \sum_{k \ge 0} z^k \right) \\
    &= [z^n] \frac{z}{1 - z}
               \cdot \left( 1 + z + z^2 \right) 
               \cdot \frac{1}{1 - z^2} 
               \cdot \frac{1}{1 - z} \\
    &= [z^n] \frac{z (1 + z + z^2)}{(1 - z)^2 (1 - z^2)} \\
    &= [z^n] \left( 
                - \frac{1}{8} \frac{1}{1 + z}
                   + \frac{7}{8} \frac{1}{1 - z}
                   - \frac{9}{4} \frac{1}{(1 - z)^2}
                   + \frac{3}{2} \frac{1}{(1 - z)^3}
             \right) \\
    &= -\frac{1}{8} (-1)^n
          + \frac{7}{8}
          - \frac{9}{4} (-1)^n \binom{-2}{n}
          + \frac{3}{2} (-1)^n \binom{-3}{n} \\
    &= - \frac{1}{8} (-1)^n
          + \frac{7}{8}
          - \frac{9}{4} \binom{n + 2 - 1}{2 - 1}
          + \frac{3}{2} \binom{n + 3 - 1}{3 - 1} \\
    &= - \frac{1}{8} (-1)^n
          + \frac{7}{8}
          - \frac{9}{4} (n + 1)
          + \frac{3}{2} \frac{(n + 2) (n + 1)}{2} \\
    &= \frac{18 n^2 + 3 - 3 \cdot (-1)^n}{24}     
\end{align}$         
Tanks to maxima for the heavy lifting.         
</s>