Show that $\widehat{\mathbb Z}\cong \prod_{p\;\text{prime number}}\mathbb Z_p$ Let $\widehat{\mathbb Z}=\varprojlim_n \; \mathbb Z/n\mathbb Z$ be the inverse limit of the inverse system $(\mathbb Z/n\mathbb Z)_{n\in \mathbb N}$ and let $\mathbb Z_p=\;\varprojlim_n\; \mathbb Z/p^n\mathbb Z$ where $p$ is a prime number. The finite rings $\mathbb Z/n\mathbb Z$ are given the discrete topology, $\widehat{\mathbb Z}$ and $\mathbb Z_p$ the subspace topologies of the product topology.  

How would I go about showing that $\widehat{\mathbb Z}\cong \prod_{p\;\text{prime number}}\mathbb Z_p$ as topological rings? 

If $N\geq 1$ then the prime factorisation $N=p_1^{r_1}\cdot \cdot \cdot p_h^{r_h}$ gives $\mathbb Z/N\mathbb Z\cong \prod_i \mathbb Z/{p_i^{r_i}\mathbb Z}$ and assuming that inverse limits commute with products I can intuitively see how the isomorphism can hold but I am not sure about the details. 
I'd be very grateful for some help (hints will also be appreciated). Many thanks. 
 A: For each prime $p$, and each integer $k\geq 1$, there is a canonical continuous homomorphism $\widehat{\mathbf{Z}}\to\mathbf{Z}/p^k\mathbf{Z}$ (by definition of the inverse limit), and these are compatible (again by definition of the inverse limit) as $k$ changes, so we get a canonical continuous homomorphism 
$$\widehat{\mathbf{Z}}\to\varprojlim_{k\geq 1}\mathbf{Z}/p^k\mathbf{Z}=:\mathbf{Z}_p$$
for each prime $p$. Explicitly, it sends a compatible sequence $(x_n+n\mathbf{Z})_{n\geq 1}$ to $(x_{p^k}+p^k\mathbf{Z})_{k\geq 1}$. The universal property of the product topology then allows us to package these together into a continuous homomorphism $\widehat{\mathbf{Z}}\to\prod_p\mathbf{Z}_p$. The map is closed because the source is compact and the target is Hausdorff, so to show that it is a topological isomorphism, we just need to show injectivity and surjectivity.
Why is the map injective? Say $(x_n+n\mathbf{Z})$ is sent to zero. Then its component in each $\mathbf{Z}_p$ is zero, which means $x_{p^k}\in p^k\mathbf{Z}$ for all primes $p$ and all $k\geq 1$. Fix an integer $n$, and factor it as $n=p_1^{k_1}\cdots p_r^{k_r}$, so $\mathbf{Z}/n\mathbf{Z}\simeq\prod_{i=1}^r\mathbf{Z}/p^{k_i}\mathbf{Z}$. By compatibility of the sequence $(x_n+n\mathbf{Z})$, because $p_i^{k_i}$ divides $n$, we have $x_n+p_i^{k_i}\mathbf{Z}=x_{p^{k_i}}+p^{k_i}\mathbf{Z}=p^{k_i}\mathbf{Z}$, so $x_n$ is divisible by $p_i^{k_i}$. This is true for all $i$, so $n\mid x_n$, and $x_n+n\mathbf{Z}=n\mathbf{Z}$. Our element is thus equal to zero.
Why is the map surjective? Note that $\widehat{\mathbf{Z}}\to\prod_p\mathbf{Z}_p$ is a ring map, and the image of $\mathbf{Z}$ in the source is dense. By compactness of the source and Hausdorffness of the target (again), it suffices to show that the image of $\mathbf{Z}$ in $\prod_p\mathbf{Z}_p$ is dense. If we project to any factor, then we definitely have density. Now a basic open subset of the product has the form $\bigcap_{i=1}^r \pi_{p_i}^{-1}(a_i+p^{k_i}\mathbf{Z}_p)$ for finitely many primes $p_i$, where $\pi_{p_i}$ is projection to the $p_i$-th factor. We may assume each $a_i$ is an integer (using the aforementioned density of $\mathbf{Z}$ in each $\mathbf{Z}_{p_i}$). Now, again using the CRT, choose an integer $m$ which is congruent to $a_i$ modulo $p_i^{m_i}\mathbf{Z}$ for all $i$. Then this integer $m$ will have image in $\prod_p\mathbf{Z}_p$ in the given open set. This proves the desired density, from which surjectivity follows.
