Solution (source code)

= Solution

The homogeneous <linear recurrence relation>
$$
y_{n+2}-4y_{n+1}+4y_n=0
$$
has characteristic polynomial $(r-2)^2$, so
$$
y_n^{(h)}=(C+Dn)2^n.
$$
For a particular solution, substitute $y_n=an+b$. The left-hand side becomes
$$
an+(b-2a),
$$
so matching $n$ gives $a=1$ and $b=2$. Hence
$$
y_n=(C+Dn)2^n+n+2.
$$
The conditions $y_0=1$ and $y_1=0$ give $C=-1$ and $D=-1/2$. Therefore
$$
\boxed{y_n=n+2-\left(1+\frac n2\right)2^n}.
$$