TITLE: Prove that $(\mathbb{Z},d)$ is a metric space
QUESTION [8 upvotes]: I got this from Mendelson:
  Let   $\mathbb {Z}$  be the set of integers.Let $p$ be a positive prime integer. Given distinct integers $m$, $n$ there´s a unique integer $t=t(m,n)$ such that:
$$ m-n=p^tk $$
where $k$ is an integer not divisible by $p$. Define a function $d:\mathbb {Z} \times \mathbb {Z}\rightarrow \mathbb {R}$ by the correspondence
$$d(m,m)=0$$
and
$$d(m,n)=\frac{1}{p^t}$$
from $m \neq n.$
Prove that $(\mathbb {Z,d})$ is a metric space.
I would appreciate a better explanation to this question. I didn´t get the $t(m,n)$. This is also a distance,right?

REPLY [4 votes]: Let $x, y, z$ be integers.
It suffices to prove that $d(x, z) \leq d(x, y) + d(y, z)$.
If two of $x, y, z$ are equal, this is trivial.
So we can assume they are distinct.
Let $x - y = p^k a$, where $a$ is not divisible by $p$.
Let $y - z = p^s b$, where $b$ is not divisible by $p$.
We can assume $k \leq s$.
Then $x - z = (x - y) + (y - z) = p^k a + p^s b = p^k(a + p^{s-k}b)$.
Suppose $x - z = p^r c$, where $c$ is not divisible by $p$.
Then $r \geq k$.
Hence $d(x, z) = 1/p^r \leq 1/p^k = d(x, y) \leq d(x, y) + d(y, z)$.
And we are done.