$p$-adic completion of integers I'm trying to do the following exercise:
Let $p$ be a prime and for $n\geq 1$ let $\alpha_n :\mathbb Z/p \mathbb Z \to \mathbb Z/p^n \mathbb Z$ be the injection of  abelian groups given by $1 \mapsto  p^{n−1}$. Consider the direct sum $\alpha  : A \to B$ of these maps where $A$ is a countable direct sum of copies of $\mathbb Z/p \mathbb Z$ and $B$ is the direct sum of the groups $\mathbb Z/p^n \mathbb Z$. Show that the $p$-adic completion of $A$ is just $A$ but that the completion of $A$ for the topology induced from the $p$-adic topology on $B$ is the direct product of the $\mathbb Z/p \mathbb Z$. Deduce that $p$-adic completion is not a right exact functor on the category of all $\mathbb Z$-modules.
At first I thought $A$ was just the normal integers but it's not since for example for $p=2$, $-1 = 01111\dots$ is not in the space. The direct sum are all things with only finitely many non-zero terms, so for example the sequence $a_0 = 10000\dots a_1 = 110000\dots, a_2 = 111000\dots$ is a sequence in $A$ with a limit not in $A$. 
I guess I am confused about what "$p$-adic completion" means: I assumed it meant that I take the equivalence classes of Cauchy sequences (Cauchy with respect to $|\cdot|_p$) where two sequences are equivalent if their difference tends to zero. But if that was what "$p$-adic completion" really meant then the sequence $a_k$ I gave above would be Cauchy and didn't have a limit in $A$ which is a counter example to what the exercise asks me to show. 
Would someone explain to me what "$p$-adic completion" means? Thanks.
Edit
I'm bumping this question because the answerer is on holiday and I still have a bunch of questions. Thanks for your help.
 A: I thought it would be a good exercise to post an answer of my own:
(i) We want to know the completion of the topological ring $A = \bigoplus_{n \in \mathbb N} \mathbb Z / p \mathbb Z$ with respect to the $p$-adic topology, i.e., the topology induced by neighbourhoods of zero of the form $A_n = p^n A$ so that $A=A_0 \supset A_1 \supset A_2\supset \dots$. 
From chapter 10 in Atiyah-MacDonald we know that since this is a topological Abelian group with a countable neighbourhood basis of zero such that $A_n \supset A_{n+1}$, the completion is isomorphic to the inverse limit of the inverse system $X_n = A/A_n$ and the transition maps $f_n : A/A_n \to A/A_{n-1}$, $(x \mod p^{n}) \mapsto (x \mod p^{n-1})$. But since $pA = 0$ we get $X_n = A$ and $f_n = id_A$. Now the inverse limit are sequences $\vec{a} \in \bigoplus_n A/A_n = \bigoplus_n A$ such that $id(a_n) = a_{n-1}$, that is, constant sequences. Now clearly, $\varprojlim_n A \cong A$ via the map $(a,a,a, \dots ) \mapsto a$.

(ii) Next we would like to compute the completion of $A$ with respect to the topology induced by the $p$-adic topology on $B = \bigoplus_n \mathbb Z / p^n \mathbb Z$. The map $\alpha : A \to B$ is the inclusion map so that a set $U$ is a neighbourhood in $A$ if and only if $\alpha^{-1}(V) = V \cap A = U$ for $V$ open in $B$. Open sets in $B$ are of the form $p^k B$. Since $B = \bigoplus_n \mathbb Z / p^n \mathbb Z$, $p^k B = \bigoplus_{n=0}^{\infty} p^k \mathbb Z / p^n \mathbb Z$ where for $n \leq k$ the component is zero. We compute the inverse image $\alpha^{-1}(p^kB)$ as follows: Let $(A)_n = \mathbb Z / p \mathbb Z$ be the $n$-th component of $A$. For the $n$-th component of $p^k B$ we get 
$$ (p^kB)_n =
\begin{cases}
0 & n \leq k \\
p^k \mathbb Z / p^n \mathbb Z & n > k\\
\end{cases}
$$
We have $\alpha(A)_n =  \alpha_n(\mathbb Z / p \mathbb Z) = p^{n-1} \mathbb Z / p^n \mathbb Z$ so that 
$$ \alpha^{-1}(p^k B) =  
\begin{cases}
0 & n \leq k \hspace{0.2cm} (\text{since } \alpha \text{ is injective}) \\
\mathbb Z / p \mathbb Z & n > k \hspace{0.2cm} (\text{since } \mathrm{im}(\alpha ) = p^{n-1} \mathbb Z / p^n \mathbb Z \subset p^{k} \mathbb Z / p^n \mathbb Z)\\
\end{cases}$$
Hence open sets in this topology on $A$ look like $O_k = 0 \oplus \dots \oplus 0 \oplus \mathbb Z / p \mathbb Z \oplus \mathbb Z / p \mathbb Z \dots $ where the first $k$ entries are zero.
For our inverse system this gives us $X_n = A / O_k = \mathbb Z / p \mathbb Z \oplus \dots \oplus \mathbb Z / p \mathbb Z \oplus 0 \oplus \dots $ where the first $k$ entries are non-zero. For the transition maps $t_n: X_n \to X_{n-1}$ this means $(x_1, x_2, \dots,x_{k-1}, x_k, 0 , 0 , \dots) \mapsto  (x_1, x_2, \dots,x_{k-1}, 0 , 0 , \dots)$.
For the inverse limit of this system this means that it is all sequences with $x_n \in X_n$, which gives us $\varprojlim_n X_n = \prod_n X_n = \prod_n \mathbb Z / p \mathbb Z$.

Now to conclude that $\varprojlim_n$ is not a right-exact functor on $\mathbb Z - \mathrm{\mathbf{Mod}}$, let $A_k = \alpha^{-1}(p^k B)$. Then the following sequence is exact:
$$ 0 \to A_k \hookrightarrow A \xrightarrow{\pi_k} A/A_k \to 0$$
But for the inverse limit we get
$$ 0 \to 0 \hookrightarrow A = \bigoplus_n \mathbb Z / p \mathbb Z \xrightarrow{\pi} \prod_n \mathbb Z / p \mathbb Z $$
where $\pi$ cannot be surjective since it is a group homomorphism mapping zero in the $n$-th component to zero. 
A: The $p$-adic completion should mean “complete with respect to the ideal generated by $p$”. I guess the discussion is restricted to groups, so you could instead think about completing with respect to the subgroup filtration $(p^nG)$. I would forget about the metric for the time being.
For $A$ we have $pA = 0$, so to complete we're taking the inverse limit
\[
A \leftarrow A \leftarrow \cdots
\]
in which all of the transition maps are the identity. This is clearly isomorphic to $A$.
Now we want to see what happens if we complete $A$ with respect to the filtration $(C_n) = (p^nB \cap A)$. So what you should do is write out $p^nB$ and $\alpha(A)$, and then compute these $C_n$. It should come out that $A/C_n = \bigoplus_{i = 1}^n \mathbb Z/p\mathbb Z$, and that the transition map $A/C_{n + 1} \to A/C_n$ forgets the $(n + 1)$-th component. Does the result seem plausible now?
