<s>[INST] Recurrence relation $a_n = -a_{n-1}+n -1 , a_0=7$ $a_n = -a_{n-1} +n -1  ,   a_0=7$
I am trying to find an explicit formula for this recurrence relation by using backward iteration.
So far I've ended up with this and I don't know what to do to find an explicit formula for this.
$a_n = -a_{n-1}+n -1 , a_0=7$
$= -a_{n-1} +n -1$
$= a_{n-2} +1$
$= -a_{n-3} +n -2$
$= a_{n-4} +2$
$= - a_{n-5} +n-3$
$= a_{n-6} +3$
......
 [/INST] I think you already discovered this pattern:
$$\begin{array}\\
a_n &=& a_{n-0} +0\\
&=& a_{n-2} +1\\
&=& a_{n-4} +2\\
&=& a_{n-6} +3\\
&\ldots
\end{array}$$
So for even $n$, $n=2m,$ we have
$$\begin{array}\\
a_{2m} &=& a_{2m-0} +0\\
&=& a_{2m-2} +1\\
&=& a_{2m-4} +2\\
&=& a_{2m-6} +3\\
&\ldots\\
&=& a_{2m-2m} +m\\
&=& a_{0} +m\\
&=& 7 +m\\
\end{array}$$
and for odd $n$, $n=2m+1$, we have
$$\begin{array}\\
a_{2m+1} &=& a_{2m+1-0} +0\\
&=& a_{2m+1-2} +1\\
&=& a_{2m+1-4} +2\\
&=& a_{2m+1-6} +3\\
&\ldots\\
&=& a_{2m+1-2m} +m\\
&=& a_{1} +m\\
&=& -7 +m\\
\end{array}$$
</s>