How to tell if products of cyclic groups are isomorphic?

How to tell if a product of cyclic groups $C_{n_1}\times C_{n_2} \times ...\times C_{n_k}$, where $n_1+n_2+...+n_k=N$, is isomorphic to another product of cyclic groups $C_{m_1}\times C_{m_2} \times ...\times C_{m_j}$, where $m_1+m_2+...m_j=M$, given that $N=M$?

• You probably mean $n_1 \cdot n_2 \cdots n_k = N$. – lhf Aug 3 '17 at 18:37
• I wonder whether we can do this without factoring, just using gcd and lcm. It works $k=2$. – lhf Aug 3 '17 at 18:39

Write each of $n_1, n_2,\dots, n_k$ and each of $m_1,m_2,\dots, m_j$ as a power of prime powers to obtain the list of elementary divisors of each product and compare these lists. The groups are isomorphic if and only if these lists are equal.
So, in your case, you would just have to factor each $n_i$ and $m_i$ into their prime power factors, and then compare the (multi-)sets of all prime power factors of all the $n_i$s with that of all the $m_i$s.