By considering \((1+x+x^{2}+\cdots+x^{n})(1-x)\) show that, if \(x\neq1\),
\[
1+x+x^{2}+\cdots+x^{n}=\frac{1-x^{n+1}}{1-x}.
\]
By differentiating both sides and setting \(x=-1\) show that
\[
1-2+3-4+\cdots+(-1)^{n-1}n
\]
takes the value \(-n/2\) is \(n\) is even and the value \((n+1)/2\) if
\(n\) is odd.
Show that
\[
1^{2}-2^{2}+3^{2}-4^{2}+\cdots+(-1)^{n-1}n^{2}=(-1)^{n-1}(An^{2}+Bn)
\]
where the constants \(A\) and \(B\) are to be determined.