How to derive the closed form of this recurrence? For the recurrence, $T(n) = 3T(n-1)-2$, where $T(0)= 5$, I found the closed form to be $4\cdot 3^n +1$(with help of Wolfram Alpha). Now I am trying to figure it out for myself. So far, I have worked out: $T(n-1) = 3T(n-2)-2, T(n-2) = 3T(n-3)-2, T(n-3) = 3T(n-4)-2$ leading me to: $T(n)=81\cdot T(n-4)-54-18-6-2 $ etc. I have noticed the constants follow a Geometric Series whose sum is given by $1-3^n$. I am having trouble putting this together to end up with the final closed form.

Multiply the recursion by $3^{-n}$:
$$
3^{-n}T(n)=3^{-n+1}T(n-1)-2\cdot3^{-n}
$$
Thus,
$$
3^{-n}T(n)=-2\cdot3^{-n}-2\cdot3^{-n+1}-\dots-2\cdot3^{-1}+T(0)
$$
Multiply by $3^n$:
$$
\begin{align}
T(n)
&=-2\cdot3^0-2\cdot3^1-\dots-2\cdot3^{n-1}+3^nT(0)\\[3pt]
&=-2\frac{3^n-1}{3-1}+3^nT(0)\\[4pt]
&=-3^n+1+3^nT(0)\\[4pt]
&=4\cdot3^n+1
\end{align}
$$
