Solution (source code)

= Solution

Substitution of $y_n=r^n$ gives the <characteristic equation of a linear recurrence>
$$
r^3-3r+2=(r-1)^2(r+2)=0.
$$
The <repeated characteristic root of a linear recurrence> $1$ supplies the solutions $1$ and $n$, while the simple root $-2$ supplies $(-2)^n$. They are linearly independent: their values at three consecutive indices have nonzero determinant. A third-order <linear recurrence relation> is uniquely determined by three consecutive initial values, so these three solutions span its solution space. \b[The general solution is]
$$
\boxed{y_n=A+Bn+C(-2)^n.}
$$