What is the number of ring isomorphisms from $\mathbb{Z}^n$ to $\mathbb{Z}^n$. Yesterday, I faced the problem : what is the number of ring isomorphisms from $\mathbb{Z}^2$ to $\mathbb{Z}^2$. And I got $6$. After then, I found that if $n=3$, the number is $3! \times 29$. Suddenly, I wondered what is the number of isomorphisms from $\mathbb{Z}^n$ to $\mathbb{Z}^n$. I have tried to solve it but failed. What's more, I couldn't find any answers about that on google. Is it easy to solve? I tried to solve the problem by using recursive relation. But it looks difficult.
One of my friends gave me a suggestion to find the number of $n \times n$ invertible matrices with components $1$ or $0$. At first, we thought that it is exactly $(2^n-1)(2^n-2) \dots (2^n-2^{n-1})$. But this equation doesn't work because the construction of the equation discards some cases. For example, $n=3$, the equation discards $ (\begin{smallmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 1 \end{smallmatrix} )$. The equation only works on a finite field. I found that it is a lower bound and upper bound $((n+1)!)^2 2^\frac{n(n+1)}{2}$ by a recursive relation. But I don't know until now what is the exact number of that.
+
Due to Perter Franek, I solved it. The answer is $n!$.
Idempotent elements should go idempotent elements and if $\phi$ is an isomorhpism, then $\phi(0)$ implies $0$. The candidates of $e_i=(\delta_{ij})_j$ are each or sum of $\{e_i\}$'s. But if some $e_i$ goes to sum of $e_i's$, $0=\phi(e_i e_j)= \phi(e_i) \phi(e_j) \not =0$ for some $i \not = j$.
 A: 
One of my friends gave me a suggestion to find the number of $n×n$ invertible matrices with components $1$ or $0$.

This is OEIS A055165; there appears to be no simple formula for it.
A: Any ring homomorphism $\phi$ sends idempotents (elements $e$ satisfying $e^2=1$) to idempotents. The idempotents of $\mathbb{Z}^n$ are the vectors with coordinates all $0$ or $1$. These correspond to subsets of $\{1,\cdots,n\}$ (to describe where the $1$s occur in the coordinates). Thus, if $e_1,\cdots,e_n$ refer to the standard basis vectors of $\mathbb{Z}^n$, there are subsets $A_1,\cdots,A_n\subset\{1,\cdots,n\}$ for which
$$ \phi(e_i)=\sum_{a\in A_{\Large i}}e_a. $$
Moreover, ring homomorphisms preserve zero division. That is, $e_ie_j=0$ (when $i\ne j$) implies
$$ 0=\phi(e_i)\phi(e_j)=\Big(\sum_{a\in A_{\Large i}}e_a\Big)\Big(\sum_{b\in A_{\Large j}} e_{b}\Big)=\sum_{c\in A_{\Large i}\cap A_{\Large j}}e_c.  $$
This implies the $A_1,\cdots,A_n$ are disjoint. They must be nonempty, else $\phi$ would have a kernel, so
$$ n=1+\cdots+1\le |A_1|+\cdots+|A_n|=|A_1\cup\cdots\cup A_n|\le n. $$
The only way this inequality is squeezed so tightly is if $|A_i|=1$ for each $i$. Thus, $\phi$ simply permutes the standard basis vectors $e_1,\cdots,e_n$, and there are $n!$ such permutations!
