Finding a formula for a sequence Let $a_n$ be a sequence such that $a_0=5$ and $a_{n}+a_{n+1}=3$ for all $n$ greater than $0$.
I defined a function $f(x)$ whose coefficients are same of that mentioned sequence.
I was able to get $$f(x)=\displaystyle \sum_{n=0}^\infty [ 5 (-1)^n x^n + 3 (-1)^n x^{n+1} + 3 x^{2n+1} ] $$
But couldn't make it far.
How do you find a formula for $a_n$ given that $a_1$ is just $1$?


Let an be a sequence such that $a_0=5$ and $a_n+a_{n+1}=3$ for all $n$ greater than $0$.

First note: $a_0+a_1=3 \Rightarrow 5+a_1=3 \Rightarrow a_1=-2$.
It looks you are trying to use the generating function $f(x)=\sum_{n=0}^{\infty} a_nx^n$. Here are the steps:
$$\sum_{n=0}^{\infty} a_nx^{n+1}+\sum_{n=0}^{\infty} a_{n+1}x^{n+1}=3\sum_{n=0}^{\infty} x^{n} \Rightarrow \\
xf(x)+f(x)-a_0=3\cdot \frac1{1-x} \Rightarrow \\
f(x)=\frac{5-2x}{(1-x)(1+x)}=\frac7{2(1+x)}+\frac3{2(1-x)}=\\
\frac72\sum_{n=0}^{\infty}(-x)^n+\frac32\sum_{n=0}^{\infty} x^n =\\
\sum_{n=0}^{\infty}\left[\frac72(-1)^n+\frac32\right]x^n \Rightarrow \\
a_n=\frac72(-1)^n+\frac32.$$
Can you solve the recurrence relation $a_n+a_{n+1}=3$, if $a_0=2, a_1=1$?
