[Number Theory]
Problem: 
Find (in closed form) the difference between the number of positive integers at most $2^{2017}$ with even weight and the number of positive integers at most $2^{2017}$ with odd weight.

Solution: For every integer $M \geq 0$, let $A_{M}=\sum_{n=-2^{M}+1}^{0}(-1)^{w(n)}$ and let $B_{M}=$ $\sum_{n=1}^{2^{M}}(-1)^{w(n)}$; thus, $B_{M}$ evaluates the difference of the number of even weight integers in the range 1 through $2^{M}$ and the number of odd weight integers in that range.



Notice that



$$

w(n)= \begin{cases}w\left(n+2^{M}\right)+1 & \text { if }-2^{M}+1 \leq n \leq-2^{M-1} \\ w\left(n-2^{M}\right) & \text { if } 2^{M-1}+1 \leq n \leq 2^{M}\end{cases}

$$







to get



$$

\begin{aligned}

& A_{M}=-\sum_{n=-2^{M}+1}^{-2^{M-1}}(-1)^{w\left(n+2^{M}\right)}+\sum_{n=-2^{M-1}+1}^{0}(-1)^{w(n)}=-B_{M-1}+A_{M-1}, \\

& B_{M}=\sum_{n=1}^{2^{M-1}}(-1)^{w(n)}+\sum_{n=2^{M-1}+1}^{2^{M}}(-1)^{w\left(n-2^{M}\right)}=B_{M-1}+A_{M-1} .

\end{aligned}

$$



Iteration yields



$$

\begin{aligned}

B_{M} & =A_{M-1}+B_{M-1}=\left(A_{M-2}-B_{M-2}\right)+\left(A_{M-2}+B_{M-2}\right)=2 A_{M-2} \\

& =2 A_{M-3}-2 B_{M-3}=2\left(A_{M-4}-B_{M-4}\right)-2\left(A_{M-4}+B_{M-4}\right)=-4 B_{M-4}

\end{aligned}

$$



Thus, $B_{2017}=(-4)^{504} B_{1}=2^{1008} B_{1}$; since $B_{1}=(-1)^{w(1)}+(-1)^{w(2)}=2$, it follows that $B_{2017}=$ $2^{1009}$

Final answer: $2^{1009}$