Consider the following metric on $\mathbb{Z}$. We fix a prime number $p$. If $x \neq y$, then $d(x, y)= \frac{1}{p^n}$, where $n$ is the largest integer such that $p^n$ divides $y-x$ and $0$ when $x = y$. Is $(\mathbb{Z}, d)$ compact?
Approach: I can't prove it as compact but here $0 \leq d(x,y) \leq 1$ and there are many numbers whose distance is $1$ [$d(x,y)=1$]. This reminds me of discrete metric So I feel like $(\mathbb{Z},d)$ might not be compact. And we can consider the open cover $B(x,\frac{1}{2})$ where $x\in \mathbb{Z}$ i.e $\mathbb{Z} \subset \bigcup_{x\in \mathbb{Z}} B(x,\frac{1}{2}) $ and if it were compact then we can find a finite subcover say $\mathbb{Z} \subset B(a_1,\frac{1}{2}) \cup... \cup B(a_n, \frac{1}{2})$ but I can't find an element which is in $\mathbb{Z}$ but lies outside the union. Please help I can't proceed further
Choose $r \ge 2$ with $gcd(r,p)=1$.
Let $U_n := \{x \in \mathbb Z: \lvert rx -1 \rvert > p^{-n}\}$.
Check that all $U_n$ are open (e.g. ultrametric maximum principle). Obviously, $U_n \subseteq U_{n+1}$ for all $n$.
The union of all $U_n$ is $\mathbb Z$: For every $x \in \mathbb Z$, we have $\lvert rx - 1 \rvert > 0$ and hence $> p^{-m}$ for some $m \in \mathbb N$.
But any finite subcover is just some $U_k$, which does not cover $\mathbb Z$: There are infinitely many $x \in \mathbb Z$ such that $rx \equiv 1$ modulo $p^k$ i.e. $\lvert rx -1 \rvert \le p^{-k}$.
(What I am secretly doing here is just saying that $1/r \in \mathbb Z_p$ ($p$-adic numbers) lies in the closure of $\mathbb Z$ but not in $\mathbb Z$ itself.)
Note that contrary to what some comments and deleted answers suggest, you will not be able to find infinitely many integers all of whose mutual distances are $1$, or indeed any infinite list of integers whose mutual distances have an infimum $> 0$. As @markvs points out in comments, indeed every sequence in $\mathbb Z$ with respect to the $p$-adic metric has a subsequence which is Cauchy, and this follows from the fact that its closure / completion in that metric, the set of $p$-adic integers $\mathbb Z_p$, indeed is compact. [In fact, one can show that the maximum number of mutually disjoint open balls all of whose radii are $\ge p^{-k}$, is $p^{k+1}$, and since in the $p$-adic metric such open balls are either disjoint or one is contained in the other, it is impossible to find "truly infinite" covers with open balls whose radii are bounded away from $0$.] Every counterexample to compactness of $\mathbb Z$ with the $p$-adic metric will in one disguise or another construct such a Cauchy sequence whose limit point lies outside of $\mathbb Z$.