$M(n)=3M(n−1)+1$ with base case of $M(1)=1$
Somehow I'm not understanding how to solve the recurrences.
This problem is from my textbook and I was fine until I see this in example. I know it goes like: $M(1)=3\times M(0)+1=1$
$M(2)=3\times 1+1=4$
$M(3)=3\times 4+1=13$
Can I have some hints?
For large enough $n$, $$ M(n)=3M(n-1)+1\\ M(n)=3(3M(n-2)+1)+1\\ M(n)=9M(n-2)+4\\ M(n)=9(3M(n-3)+1)+4\\ M(n)=27M(n-3)+13\\ M(n)=27(3M(n-4)+1)+13\\ M(n)=81M(n-4)+40\\ M(n)=81(3M(n-5)+1)+40\\ M(n)=243M(n-5)+121\\ $$ Keep going until you notice a pattern.
Eventually you will realize that $M(n)=3^{n-1}M(1)+\frac{3^{n-1}-1}{2}=\frac{3^n-1}{2}$.
You can prove this by induction:
The base case is true: $M(1)=\frac{3^1-1}{2}=1$
Now suppose $M(n)=\frac{3^n-1}{2}$. Then $M(n+1)=3M(n)+1=3*\frac{3^n-1}{2}+1=\frac{3^{n+1}-3}{2}+1=\frac{3^{n+1}-1}{2}$. Thus we have proven that $M(n)=\frac{3^n-1}{2}$.