$$\displaystyle{\displaylines{g(0)=1}}$$ $$\displaystyle{\displaylines{g(n)=3^n-g(n-1)+1}}$$
Find the analytical definition of the recurrence relation using iteration $$\displaystyle{\displaylines{g_{1}=3^1-1+1=3}}$$ $$\displaystyle{\displaylines{g_{2}=3^2-(3-1+1)+1=3^2-3+1-1+1=7}}$$ $$\displaystyle{\displaylines{g_{3}=3^3-3^2+3-1+1-1+1=7}}$$ $$\displaystyle{\displaylines{g_{4}=3^4-3^3+3^2-3+1-1+1-1+1=21}}$$ $$\displaystyle{\displaylines{g_{5}=3^5-3^4+3^3-3^2-1+1-1+1-1+1=61}}$$
My Guess so far $$\displaystyle{\displaylines{g(n)=3^n-3^{n-1}+3^{n-2}-3^{n-3}...+(-1)^n3^0}}$$ The problem I am having is figuring out what to do about the +1 at the end.
Every even index n>0 ends with +1 and every odd index does not have a +1 at the end making it hard to use sum of geometric sequence.
Any ideas where to go from here would be greatly appreciated.