Suppose $A$ is a finite abelian group.
(a) Extract from the function $h_A(n) = |\{x \in A : x^n = e\}|$ ($n \in \mathbb{Z}$) the elementary divisors of A using the fact that for a cyclic group $C$ of order $N$, $h_C(n) = \mathrm{gcd}(n,N)$
(b) Use part (a) to show that finite abelian groups are isomorphic if and only if their elementary divisors are the same.
I am thinking that we may factor $A$ as $A = A' \times \mathbb{Z}_n$, where $h_A(n) = e$ and then factor $A'$ using the same algorithm, etc. Although I am not sure if this is idea is correct and if so how to complete the answer based on it. Thank you.