Solution to the recurrence relation I came across following recurrence relation:


*

*$T(1) = 1, $

*$T(2) = 3,$

*$T(n) = T(n-1) + (2n-2)$ for $n > 2$.


And the solution to this recurrence relation is given as 
$$T(n)=n^2-n+1$$
However I am not able to get how this is obtained.

$C=const$ is the solution of the homogeneous equation $T(n)=T(n-1)$ and $n^2-n$ is a solution of the inhomogeneous equation since $n^2-n=(n-1)^2-(n-1)+2n-2$
