Define $d$ on $\mathbb Z \times \mathbb Z$ by,
$d(x,y)=0 $ if $x=y$ and $d(x,y)=m^{-1}$,where $m$ is the largest positive integer such that $10^{m-1}$ divides $(x-y)$.
Show that the function defines a metric on $\mathbb Z$. I am having problem with the triangle inequality.Can someone please help me?
If either $x=y$ or $y=z$, then the triangle inequality is clear. Otherwise, $d(x,y)$ is $\frac{1}{n+1}$, where $n$ is the number of common trailing digits of $x$ and $y$, assuming that they have the same sign. Ditto for $d(x,z)$ and $d(y,z)$.
Now, suppose that $x$ and $y$ have $m$ common trailing digits, and $y$ and $z$ have $n$ common trailing digits. If $m=n$, then $x$ and $z$ would have at least $n$ common trailing digits, let's say $p$. Then, $d(x,z)=\frac{1}{p+1} \le \frac{1}{n+1} \leq \frac{1}{n+1}+\frac{1}{n+1}=d(x,y)+d(y,z)$. Otherwise, $x$ and $z$ would have $p:=\min(m,n)$ common trailing digits, and then $d(x,z)=\frac{1}{p+1}=\max(\frac{1}{m+1}, \frac{1}{n+1})=\max(d(x,y),d(y,z))$.
Hence, we have an ultrametric space.