I am told that finite groups have unique factorization under direct product. That is, call a nontrivial group "indivisible" if it is not isomorphic to a direct product of nontrivial groups. Then every finite group can be "factored" (by direct product) into a unique collection of indivisible groups.
In particular, if $G$ and $H$ are finite groups so that $G\times G\cong H\times H$, then $G\cong H$.
Can anyone provide a reference to a proof of these results? What is known in the infinite case? Thanks.