$1-x+x^2-x^3+..(-1)^nx^n$ I have the following sum:
$1-x+x^2-x^3+..(-1)^nx^n, x\neq -1$
So what I thought was separating it in two cases like this:
Case 1. n is even
$$
1+x^2+x^4+...+x^n-x(1+x^2+...+x^n)
$$
Which I can turn into $\frac{1-x^{n+2}}{1-x^2}-\frac{x(1-x^{n+2})}{1-x^2}=\frac{1-x^{n+2}}{1-x^2}(1-x)$
Case 2. n is odd
$$
1+x^2+x^4+...+x^{n-1}-x(1+x^2+...+x^{n-1})=\frac{1-x^{n+1}}{1-x^2}-x(\frac{1-x^{n+1}}{1-x^2})
$$
My question is: Assuming what I've written is correct, which I'm not entirely sure, how can I combine the two cases for n even and odd into one equation?

$$S(n)=1-x+x^2-x^3+..(-1)^nx^n$$ multiply by $+x $
$$xS(n)=x-x^2+x^3...(-1)^{n-1}x^n+(-1)^nx^{n+1}$$ now find add $S(n) ,xS(n)$
so
$$s(n)+xS(n)=1+(x-x)+(x^2-x^2)+....+((-1)^{n-1}x^n+(-1)^nx^n)+(-1)^nx^{n+1}\\S(n)(x+1)=1+(-1)^nx^{n+1}\\
s(n)=\frac{1+(-1)^nx^{n+1}}{1+x}=\\
\frac{1+(-1)(-1)^{n+1}x^{n+1}}{1+x}=\\
\to \\
S(n)=\frac{1-(-1)^{n+1}x^{n+1}}{1+x}$$
