Solution (source code)

= Solution

Eliminate the free constant by comparing consecutive values:
$$
y_{n+1}-2y_n=(a2^{n+1}-n-1)-2(a2^n-n)=n-1.
$$
Therefore an appropriate <inhomogeneous linear recurrence> is
$$
\boxed{y_{n+1}-2y_n=n-1.}
$$
Its homogeneous part has solution $a2^n$, and $-n$ is a particular solution. A first-order <linear recurrence relation> has one arbitrary initial value, so this gives exactly the desired general solution.