# How do I find the recurrence equation solution for $T(n) = T(n-1) + n + 2?$ [duplicate]

Okay so I am supposed to find the recurrence equation of $T(n) = T(n-1)+n+2$, where $T(1) = 1$. I know the answer should come out to be $\dfrac12(n(n+5)-4)$ but I don't understand how to get that answer.

You have $$T(k)-T(k-1)=k+2$$ Summation of both sides from $2$ to $n$ gives you $$T(n)-T(1)=\sum_{k=2}^n(k+2)=\sum_{k=4}^{n+2}k=\frac{(n+6)(n-1)}{2}$$ $$T(n)=1+\frac{n^2+5n-6}{2}$$ $$=\frac{n^2+5n-4}{2}$$ $$=\frac{n(n+5)-4}{2}$$
Hint: Consider $a_n=T(n)-T(n-1)$ for $n\geqslant 2$. How can you express $T(n)$ in terms of $a_n$, $a_{n-1}$, $\dots$, $a_2$?