I know that if $ G_1, G_2 $ are cyclic groups then $ G_1 \times G_2 $ is cyclic if and only if $ |G_1| $ and $ |G_2| $ are coprimes. But I have to reponds a similar question in the context of category theory:
show that $ \mathbb{Z}_n $, $ \mathbb{Z}_m $ have a product in the category of cyclic groups if and only if $ n, m $ are coprimes.
For the implication $ \leftarrow \ $ I consider that $ n,m $ coprimes $ \rightarrow \mathbb{Z}_n \times \mathbb{Z}_m $ is cyclic, so this group is an element of the cateogory. Now we can take the proyection $$ p_1 : \mathbb{Z}_n \times \mathbb{Z}_m \rightarrow \mathbb{Z}_n ,\ \ \ \ p_1(x,y) = x $$ and $$ p_2 : \mathbb{Z}_n \times \mathbb{Z}_m \rightarrow \mathbb{Z}_m , \ \ \ \ p_2(x,y) = y $$ that are homomorphism. Easily I can show that $ \mathbb{Z}_n \times \mathbb{Z}_m $ and $ p_1, p_2 $ form a product of $ \mathbb{Z}_n $ and $ \mathbb{Z}_m $ in the category of cyclic groups.
But I am stuck in the proof of the implication $ \rightarrow $.
This should also follow from a naive count of the number of homomorphisms between cyclic groups: specifically, $$\lvert \operatorname{Hom}(\mathbb{Z}_a, \mathbb{Z}_b) \rvert = \gcd(a,b).$$
Suppose $\mathbb{Z}_p$ is the product of $\mathbb{Z}_m$ and $\mathbb{Z}_n$ in the category of cyclic groups. Then it satisfies universal property $$\operatorname{Hom}(\mathbb{Z}_t, \mathbb{Z}_p) \cong \operatorname{Hom}(\mathbb{Z}_t, \mathbb{Z}_m) \times \operatorname{Hom}(\mathbb{Z}_t, \mathbb{Z}_n)$$ for all $t$. Counting both sides, we obtain the relation $$\gcd(t,p) = \gcd(t,m) \cdot \gcd(t,n)$$ for all $t$. In particular, if $t = m$, we get $$\gcd(m,p) = m \cdot \gcd(m,n).$$ The left hand side is at most $m$, but in case $m, n$ are not coprime, $\gcd(m,n) > 1$, and the right hand side is strictly bigger than $m$. This would give a contradiction.