Studying $\operatorname{Hom}(G,\mathbb{Z}/2\mathbb{Z})$ where $G$ is finite. Let $G$ be a finite order group. Then we can write $|G| = 2^n(2m+1)$ for some non-negative integers $n$ and $m$. I'm trying to show that $\operatorname{Hom}(G,\mathbb{Z}/2\mathbb{Z})$ is an abelian group of order $2^s$ for some integer $s$ such that $0 \leq s \leq n$
I'm a bit stuck here. 
Attempt so far: One observation is that if $f \in \operatorname{Hom}(G,\mathbb{Z}/2\mathbb{Z})$ is nontrivial, then it is an epimorphism and so its kernel is an index 2 subgroup. Conversely, every index 2 subgroup must be the kernel of a homomorphism from $G$ to $\mathbb{Z}/2\mathbb{Z}$. So the problem is now to count subgroups. I'm not sure how to do that.
 A: There are as many morphisms to Z/2Z from G as from the abelianization of G, and the order of the latter divides the order of the former. It is therefore enough to consider the case in which G is abelian. Now an abelian G is the direct sum of its Sylow subgroups, and a homomorphism to Z/2Z vanishes on the odd sized Sylow subgroups, so that it is determined by its restriction to the Sylow 2-subgroup.
We may therefore suppose that G is a 2-group. Moreover, a morphism to Z/2Z vanishes on 2G, so we can in fact suppose that 2G is zero.
Then G is in fact a vector space over the field with two elements, and linear algebra tells us that there are as many homomorphisms to the field as elements in G. This proves what we want.
A: Let $G^2 = \langle \{x^2: x \in G\} \rangle.$ This is normal since $g^{-1}x^2 g = (g^{-1}xg))^2$. Since every element of $G/G^2$ has order at most 2, then it is abelian. Note that $G^2 \leq \ker f$ for all $f \in \operatorname{Hom}(G,\mathbb{Z}/2\mathbb{Z}).$ So (by same argument as Mariano's answer) there are as many homomorphisms as there are between $G/G^2$ and $\mathbb{Z}/2\mathbb{Z}.$ $G/G^2$ is a direct product of cyclic subgroups of order 2. Thus it is a vector space over $\mathbb{Z}/2\mathbb{Z}$ and there as many homomorphisms as there are elements of $G/G^2$. This is a group of order $2^s$ where $0 \leq s \leq n$. This gives us what we wanted.
Edit: Here are some examples of when $s$ obtains the extremes of $0$ and $n$. As suggested in Mariano's example, we will have $s = n$ if we take $G = (\bigoplus_{i=1}^n\mathbb{Z}/2\mathbb{Z}) \bigoplus \mathbb{Z}/(2m+1)\mathbb{Z}.$ 
For $k \geq 3$, take $G = A_k$ when $s = 0.$ $A_k$ is generated by $3$-cycles and $(a_1 a_2 a_3) = (a_1 a_3 a_2)^2$, so $A_k^2 = A_k$. Then $s = 0$ in this case.
