Prove that $\mathbb Z^n$ is not isomorphic to $\mathbb Z^m$ for $m\neq n$ 
Prove that $\mathbb Z^n$ is not isomorphic to $\mathbb Z^m$ for $m\neq n$.

My try:
Let $\mathbb Z^n\cong \mathbb Z^m $. To show that $m=n$.
Case 1: Let $m>n$. Now that $\mathbb Z^m$ has $m$ generators whereas $\mathbb Z^n$ has $n$  generators and an isomorphism takes a generator to generator ; that is the contradiction.
Please correct me if I am wrong.
The case  $m<n$ also follows similarly.
 A: Every group homomorphism $\phi: \mathbb Z^n \to \mathbb Z^m$ extends (uniquely) to a linear transformation $T: \mathbb Q^n \to \mathbb Q^m$ of vector spaces over $\mathbb Q$.
Moreover, $\phi$ is injective iff $T$ is injective. But $T$ injective implies $n \le m$.
Applying this to both $\phi$ and $\phi^{-1}$, we conclude that $n \le m \le n$.
A: $\mathbb{Z}^n \cong \mathbb{Z}^m$ implies $(\mathbb{Z}/2)^n \cong \mathbb{Z}^n / 2 \mathbb{Z}^n \cong \mathbb{Z}^m / 2 \mathbb{Z}^m \cong (\mathbb{Z}/2)^m$. By comparing the number of elements, we get $2^n=2^m$, i.e. $n=m$. (No linear algebra is necessary here!)
A: First proof
Suppose $\mathbb{Z}^n\cong\mathbb{Z}^m$, with $m\ne n$. Then you can find a set of $m$ free generators in $\mathbb{Z}^n$, say $\{f_1,f_2,\dots,f_m\}$. Then, for some integers $a_{ij}$, $b_{ij}$, you have
\begin{align}
f_j&=\sum_{i=1}^n a_{ij} e_i &&j=1,\dots, m\\
e_i&=\sum_{j=1}^m b_{ij} f_j &&i=1,\dots, n
\end{align}
where $\{e_1,\dots,e_n\}$ is the standard basis.
It's easy to show from this that the matrix $[a_{ij}]$ is invertible (over the integers, so, a fortiori, over the reals). But no matrix with a different number of rows and columns can have both a left and a right inverse.
Second proof
If $\mathbb{Z}^n\cong\mathbb{Z}^m$, then
$$
\mathbb{Z}^n\otimes_{\mathbb{Z}}\mathbb{Q}\cong
\mathbb{Z}^m\otimes_{\mathbb{Z}}\mathbb{Q}
$$
so
$$
\mathbb{Q}^n\cong\mathbb{Q}^m
$$
which implies $n=m$ by well known facts of linear algebra.
Proof of the more general result for any commutative ring
Let $A$ be a nontrivial commutative ring (with identity) and suppose $A^n\cong A^m$ as $A$-modules. Let $I$ be a maximal ideal of $A$; then
$$
A^n\otimes_A(A/I)\cong A^m\otimes_A(A/I)
$$
that immediately gives
$$
(A/I)^n\cong(A/I)^m
$$
as $(A/I)$-modules. Since $A/I$ is a field, we get $n=m$.
If, instead of a maximal ideal we take a prime ideal $P$ and tensor with the field of quotients of $A/P$, we get our second proof for the special case of a domain (with $(0)$ as the prime ideal).
A: @Egreg's answer above is very complete and concise, but I thought I'd add another answer just for the heck of it.
Suppose toward a contradiction that there exist distinct natural numbers $m,n\in\Bbb{N}$ with $\Bbb{Z}^n=\Bbb{Z}^m$.
Let $m\in\Bbb{N}$ the least natural number for which there exists $n\in\Bbb{N}$ with $m\neq n$ such that $\Bbb{Z}^m\cong\Bbb{Z}^n$. Then $n>m>0$. Let $\varphi:\ \Bbb{Z}^n\ \longrightarrow\ \Bbb{Z}^m$ an isomorphism and $\{e_1,\ldots,e_n\}$ free generators of $\Bbb{Z}^n$. 
As $\varphi$ is an isomorphism $\{\varphi(e_1),\ldots,\varphi(e_n)\}$ is a set of free generators of $\Bbb{Z}^n$. Then the subgroups
$$H_n:=\langle e_1,\ldots,e_{n-1}\rangle\subset\Bbb{Z}^n\qquad\text{ and }\qquad H_m:=\langle\varphi(e_1),\ldots,\varphi(e_{n-1})\rangle\subset\Bbb{Z}^m,$$
are again free, so $H_n\cong\Bbb{Z}^{n-1}$ and $H_m\cong\Bbb{Z}^{m-1}$. But then the $\varphi\vert_{H_n}:\ \Bbb{Z}^{n-1}\ \longrightarrow\ \Bbb{Z}^{m-1}$
is an isomorphism, contradicting the minimality of $m$. Hence no such $m,n\in\Bbb{N}$ exist.
