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$
......
 A: hint
$$a_n=-a_{n-1}+n-1$$
$$a_{n+1}=-a_n+n $$
thus
$$a_{n+1}-a_{n-1}=1$$
$(a_{2n}) $ and $(a_{2n+1}) $ are arithmetics.
A: 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}$$
A: Hint: Compute first $a_{2m}$ for $m\ge 1$, and show that $a_{2m}=m+7$. Then compute $a_{2m+1}$.
A: Subtracting the given equations for $n$ and $n-1$, gives
$$
\begin{align}
a_n+a_{n-1}&=n-1\tag{1a}\\
a_{n-1}+a_{n-2}&=n-2\tag{1b}\\
a_n-a_{n-2}&=1\tag{1c}
\end{align}
$$
Therefore,
$$
a_{2n}=n+a_0\tag2
$$
The equation for $n=1$ gives $a_0+a_1=0$, and therefore
$$
\begin{align}
a_{2n+1}
&=n+a_1\\
&=n-a_0\tag3
\end{align}
$$
Putting these together gives
$$
a_n=\left\lfloor\frac n2\right\rfloor+(-1)^na_0\tag4
$$
