A fair die is thrown $n$ times. Show that the probability of getting an even number of sixes is $\frac{1}{2}[ 1 + (\frac{2}{3})^{n}]$, where $0$ is counted as even number.
My solution. I have probability of getting even number of sixes as:
$\sum_{k=0}^{{\lfloor n/2\rfloor}} {n \choose 2k}(\frac{1}{6})^{2k}(\frac{5}{6})^{n-2k}$
I also know that the probability of getting an even number of sixes plus an odd number of sixes is $1$, i.e.
$$\sum_{k=0}^{{\lfloor n/2 \rfloor}} {n \choose 2k}(\frac{1}{6})^{2k}(\frac{5}{6})^{n-2k}+ \sum_{k=0}^{{\lfloor n/2 \rfloor}+1} {n \choose 2k+1}(\frac{1}{6})^{2k+1}(\frac{5}{6})^{n-2k-1} = 1$$
However I am not sure how to extract the "even" part of the expression to obtain the answer required?
Let's suppose you have a discrete random variable $X$ taking on non-negative integer values. Let $p_n=P(X=n)$. The generating function of $X$ is $$G(s)=E(s^X)=\sum_{n=0}^\infty p_ns^n.$$ Then $$G(1)=E(1^X)=\sum_{n=0}^\infty p_n=1$$ and $$G(-1)=\sum_{n=0}^\infty (-1)^np_n.$$ Adding these, $$1+G(-1)=2(p_0+p_2+\cdots)=2P(X\text{ is even}).$$
In your example, $X$ is the number of sixes in $n$ throws of a die. Then $X$ is a binomial random variable with parameters $1/6$ and $n$.
So (i) what is the generating function of a binomial random variable, and (ii) how do you apply that to the question at hand?