I am trying to prove an algorithm with input size $n$ satisties the recurence relation (for $n>=1$)
$T(n) = T(n-1)+n$ and an initial condition of $T(1)=1$ has running time in $Θ(n^2$).
By using telescope, I've got up to the point where I got
$T(n) = n+(n-1)+(n-2)+......+ 1$
But I can not go any further from this point.
I've been googling and searching for a while and I saw that
$n+(n-1)+(n-2)+......+ 1$ can be written as $\frac{n(n+1)}{2}$
Can someone explain how would I get $\frac{n(n+1)}{2}$ from $n+(n-1)+(n-2)+......+ 1$?
First note that $$ n+(n-1)+(n-2)+\cdots +1$$ Can be rewritten as $$ 1+2+\dots +n$$ Now let's use mathematical induction
Hypothesis
$$ \forall n\in\mathbb{N}:n\ge 1$$ $$ 1+2+\dots +n=\frac{n(n+1)}{2} $$ Basis Step
Let $n=1$, $$ 1=\frac{1\cdot (1+1)}{2} $$ $$ 1=\frac{1\cdot 2}{2} $$ $$ 1=1 $$ Inductive Step
Let $n=k+1$, $$ 1+2+\dots +k+(k+1)=\frac{(k+1)(k+1+1)}{2} $$ $$ 1+2+\dots +k+(k+1)=\frac{(k+1)(k+2)}{2} $$ $$ 1+2+\dots +k+(k+1)=\frac{k^2+2k+k+2}{2} $$ $$ 1+2+\dots +k+(k+1)=\frac{k^2+k}{2}+\frac{2k+2}{2} $$ $$ 1+2+\dots +k+(k+1)=\frac{k^2+k}{2}+(k+1)$$ $$ 1+2+\dots +k=\frac{k^2+k}{2} $$ $$ 1+2+\dots +k=\frac{k(k+1)}{2} $$ Therefore $$ 1+2+\dots +n=\frac{n(n+1)}{2} $$