Finite Abelian groups with the same number of elements for all orders are isomorphic Let $A$ and $B$ be finite abelian groups.
Suppose that for every natural number $m$, the number of elements of order $m$ in $A$ is equal to the number of elements of order $m$ in $B$.
Prove that $A$ and $B$ are isomorphic.

Idea
Given that these groups are finite, I think you have to use the primary decomposition theorem somehow.
 A: Here's how I would look at it. Suppose you are given the order $g$ of the group which has canonical factorization $p_1^{\alpha_1} p_2^{\alpha_n} \dots p_n^{\alpha_n}$. By the fundamental theorem of finite group your group is direct product of $n$ abelian $p$-groups, which are in turn direct products of cyclic subgroups of different orders. We want to determine for each prime which $p$-group is being used.
To do this look at the elements whose order has only $p$ as a prime divisor. Those are the elements which are of the form $(1,1,1,g,1,1\dots 1)$ These elements form a subgroup which is isomorphic to the $p$-subgroup.
So we would like to discern which subgroup it is by knowing the elements of order power of $p$.
To prove we can do this we need to prove that if 
$\mathbb Z_{p^{a_1}}\times\mathbb Z_{p^{a_2}}\dots \mathbb Z_{p^{a_r}}$ and $\mathbb Z_{p^{b_1}}\times\mathbb Z_{p^{b_2}}\dots \mathbb Z_{p^{b_s}}$ are groups of order $p^n$ with different exponents they have a different count of orders.
To see this note that the order of an element in a direct product $g=(g_1,g_2\dots g_n)$ is the least common multiple of all of the orders, in a $p$-group it is the highest order.
So go order the factors from least to greatest. and suppose they differ for the first time at factor $k$, where the first group has a larger exponent (call it $p^x$) Then that group has more elements of order $p^x$.
A: This is not true in general. Take $A = \mathbb{Q}, B = \mathbb{Q} \times \mathbb{Q}.$ Even if you assume that the groups contains "some" elements of finite order, then also it is not true. Take $A = \mathbb{Q} \times \mathbb{Z}/m\mathbb{Z}, B = \mathbb{Q} \times \mathbb{Q} \times \mathbb{Z}/m\mathbb{Z}$ where $m > 1$ is an integer.
But if you choose $A$ and $B$ to be finite, then it is true. This follows from the structure theorem of finite abelian groups. Note also that it is not true even for finitely generated abelian groups which are not finite. Take $A = \mathbb{Z}^r, B = \mathbb{Z}^s, r\neq s.$
$\bf{EDIT:}$ Let $A$ and $B$ be two finite abelian groups. Then $A \cong \mathbb{Z}/d_1\mathbb{Z} \times \mathbb{Z}/d_2\mathbb{Z} \times \cdots \times \mathbb{Z}/d_r\mathbb{Z},$ for some $d_1, d_2, \cdots ,d_r \in \mathbb{Z}$ are prime powers (not necessarily distinct). Similarly $B \cong \mathbb{Z}/e_1\mathbb{Z} \times \mathbb{Z}/e_2\mathbb{Z} \times \cdots \times \mathbb{Z}/e_s\mathbb{Z},$ for some $e_1, e_2, \cdots , e_s \in \mathbb{Z}$ are prime powers (not necessarily distinct). The numbers $d_i$ and $e_j$ are uniquely determined by $A$ and $B$ respectively. So by the given condition, we must have $r = s, d_i = e_i, \forall i.$ This shows that $A$ and $B$ are isomorphic.
