I have the following recursive function:
$f(0) = 7$
$f(n+1) = f(n) + 6n + 1$ for all integers $n => 0 $
I know the answer is $f(n) = 3n^2 + 2n + 7$ I would like to know the steps to get to this result.
I have the following recursive function:
$f(0) = 7$
$f(n+1) = f(n) + 6n + 1$ for all integers $n => 0 $
I know the answer is $f(n) = 3n^2 + 2n + 7$ I would like to know the steps to get to this result.
We have $f(n+1)=f(n)+6n+1\Rightarrow f(n+1)-f(n)=6n+1$. From that we can have $$f(1)-f(0)=6.0+1\\ f(2)-f(1)=6.1+1\\ f(3)-f(2)=6.2+1\\ ---------\\ ---------\\ ---------\\ f(n)-f(n-1)=6.(n-1)+1$$ Adding all them up together we have $$f(n)-f(0)=6\{0+1+2+........+(n-1)\}+n.1\\ f(n)-f(0)=6\frac{(n-1)(n-1+1)}{2}+n\\ f(n)=f(0)+6\frac{(n-1)n}{2}+n\\ f(n)=7+3n^2-3n+n\\ f(n)=3n^2-2n+7$$