For any $n \in \Bbb N$, let $O(n)$ be $1$ if the binary expression of $n$ contains even number of ones; and $-1$ if the binary expression of $n$ contains odd number of ones, and $Z(n)$ be $1$ if the binary expression of $n$ contains even number of zeros; and $-1$ if the binary expression of $n$ contains odd number of zeros. For example, $O(5)=1$ and $Z(5)=-1$, since $5=101$ in binary.
I want to show that $$\sum_{n = 0}^\infty O(n)x^n = \prod_{n = 0}^\infty \left(1-x^{2^n}\right). \qquad (1)$$ I have a guess that $$\prod_{n = 0}^{k} \left(1-x^{2^n}\right) = \sum_{n = 0}^{2^{k+1}-1} O(n)x^n, \qquad (2)$$ for small value of $k$. My question is, can I show $(1)$ by showing $(2)$ using induction on $k$? Or, any ideas to show it carefully?
My second question is, how to find generating function of $Z(n)$ and $Z(n)O(n)$, i.e., $$\sum_{n=0}^\infty Z(n)x^n = \ldots$$ and $$\sum_{n=0}^\infty Z(n)O(n)x^n = \ldots?$$
Thanks in advanced.