For all $n$, find the number $a_{n}$ of ways to pay $n$ euros using 1 and 2 euro coins (without considering the order).
Each way to pay $n$ euros with $r$ 1-euro coins and $s$ 2-euro coins can be encoded in the form $x^{r} x^{2 s}=x^{n}$. The integers $r$ and $s$ can be any natural numbers. The generating function of the sequence $\left(a_{n}\right)$ is therefore

$$
\sum_{n \geqslant 0} a_{n} x^{n}=\left(\sum_{r \geqslant 0} x^{r}\right)\left(\sum_{s \geqslant 0} x^{2 s}\right)=\frac{1}{1-x} \frac{1}{1-x^{2}}=\frac{1}{(1-x)^{2}(1+x)}
$$

Let's try to write this rational fraction in the form $\frac{A}{1-x}+\frac{B}{(1-x)^{2}}+\frac{C}{1+x}$ using partial fraction decomposition. Multiplying by $(1-x)^{2}$ and evaluating at $x=1$ gives $B=\frac{1}{2}$. Multiplying by $1+x$ and evaluating at $x=-1$ gives $C=\frac{1}{4}$. Finally, if we multiply by $x$ and let $x$ tend to infinity, we get $-A+C=0$, so
$A=\frac{1}{4}$. We therefore have

$$
\begin{aligned}
\sum_{n \geqslant 0} a_{n} x^{n} & =\frac{1}{2}\left(\frac{1}{(1-x)^{2}}+\frac{1}{1-x^{2}}\right) \\
& =\frac{1}{2}\left(\sum_{i \geqslant 0}(i+1) x^{i}+\sum_{j \geqslant 0} x^{2 j}\right) \\
& =\frac{1}{2}\left(\sum_{k \geqslant 0}(2 k+2)\left(x^{2 k}+x^{2 k+1}\right)\right) \\
& =\sum_{k \geqslant 0}(k+1)\left(x^{2 k}+x^{2 k+1}\right) \\
& =\sum_{n \geqslant 0}\left(\left[\frac{n}{2}\right]+1\right) x^{n}
\end{aligned}
$$

where the brackets represent the floor function. Therefore, $a_{n}=\left[\frac{n}{2}\right]+1$.

Remark: Of course, this exercise can also be done by calculating the first few terms by hand, conjecturing the formula, and proving it by induction. However, the method of generating functions has the advantage of generalizing to all problems of this type, even when the formula is much less guessable.