$\mathbb{R}$ can be viewed as the union of open-closed intervals. $\mathbb{R}=\cup^{}_{n \in \mathbb{Z}}I_n$ Where $I_n$=(n, n+1] Then it is clear that any real number will belong to exactly one of such $I_n$'s. Define a function $$ d(x,y) = \begin{cases} 0, x=y\\ |n-m|+|x-(n+1)|+|y-(m+1)|, x \neq y \;\; x \in I_n, y\in I_m \\ \end{cases} $$
Now first two conditions are easy to verify. I'm having trouble proving the triangular inequality. Actually I was looking for metric spaces in which $1/n$ doesn't converges to 0. So I was trying this metric. We can start by cases for x, y, z And if x, y, z are integers then it is easy to verify. If x, y, z are in same $I_n$ then also I verifies that triangle inequality holds. But I'm confused in other cases. Thanks in advance.