Is $(\mathbb{Z},d)$ compact? 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
 A: 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$.
A: I will start with general properties of integeres with $p$-adic metric and will provide a concrete example of a Cauchy sequence that is not convergent (which is enough to show that $\mathbb{Z}$ is not compact) later.

Lemma 1. Let $(a_n)$ be a sequence of integers. Then the series $\sum_{i=0}^\infty a_ip^i$ (or more precisely the sequence of partial sums) is a Cauchy sequence in the $p$-adic metric.

Proof. Denote by $S_n=\sum_{i=0}^n a_ip^i$ the sequence of partial sums and note that for any $n$ and any $k,t\geq n$ we have that $p^n$ divides $S_k-S_t$. Thus $d(S_k,S_t)\leq p^{-n}$ gets arbitrarily close to $0$. $\Box$

Lemma 2. Assume that $\sum_{i=0}^\infty a_ip^i$ such that $a_i\in\{0,1,\ldots,p-1\}$ converges to $0$ in the $p$-adic metric. Then $a_i=0$ for all $i$.

Proof. By assumption for any $m$ there is $k$ such that $p^m$ divides $\sum_{i=0}^n a_ip^i$ for all $n\geq k$. By taking sufficiently large $n$ we conclude that $p^m$ divides $\sum_{i=0}^{m-1} a_ip^i$. But since $0\leq a_i \leq p-1$ then
$$\sum_{i=0}^{m-1} a_ip^i\leq \sum_{i=0}^{m-1} (p-1)\cdot p^i=$$
$$=(p-1)\cdot \sum_{i=0}^{m-1} p^i=(p-1)\cdot\frac{p^m-1}{p-1}=$$
$$=p^m-1<p^m$$
All in all $0\leq \sum_{i=0}^{m-1} a_ip^i <p^m$ and so $p^m$ cannot divide it unless all $a_i=0$. $\Box$

Corollary 1. Assume that $\sum_{i=0}^\infty a_ip^i=\sum_{i=0}^\infty b_ip^i$ are both convergent to the same limit in the $p$-adic metric, and both have coefficients in $\{0,1,\ldots,p-1\}$. Then $a_i=b_i$ for all $i$.

Proof. Just apply Lemma 2 to the difference $\sum_{i=0}^\infty (a_i-b_i)p^i$. $\Box$

Corollary 2. $\mathbb{Z}$ is not complete with respect to $p$-adic metric. In particular it is not compact.

Proof. Assume that $\mathbb{Z}$ is complete. Consider the following function:
$$F:(\mathbb{Z}/p\mathbb{Z})^\mathbb{N}\to\mathbb{Z}$$
$$F\big((a_n)\big):=\sum_{i=0}^\infty a_ip^i$$
By Lemma 1 each $F\big((a_n)\big)$ is Cauchy and so our $F$ is well defined since we've just assumed that $\mathbb{Z}$ is complete. But Corollary 1 is just another way of saying that $F$ is injective. This cannot happen because of the cardinality difference between $(\mathbb{Z}/p\mathbb{Z})^\mathbb{N}$ and $\mathbb{Z}$. $\Box$
In particular the proof of the Corollary 2 shows that actually most power series of the form $\sum_{i=0}^\infty a_i p^i$ are not convergent, even though all are Cauchy.

A concrete example of such power series is as follows: let $r\in\mathbb{Z}$, $r> 1$ and consider the geometric series $\sum_{i=0}^\infty r^i$. Since $S_n=\sum_{i=0}^n r^i=\frac{1-r^{n+1}}{1-r}$ then the difference $\frac{1}{1-r}-S_n=\frac{r^{n+1}}{1-r}$. Thus if $r=p^m$ for some $m$, then $\sum_{i=0}^\infty r^i$ series converges to $\frac{1}{1-r}$ in $\mathbb{Q}$. In other words
$$\sum_{i=0}^\infty p^{mi}=\frac{1}{1-p^m}$$
for any $m\geq 1$. Note that the sum is not an integer except for $p=2$ and $m=1$ case.
Also note that the same proof of Corollary 2 works if we replace $\mathbb{Z}$ by $\mathbb{Q}$ on the right side of $F$ function. In particular $\mathbb{Q}$ under $p$-adic metric is not complete as well. A concrete example of a Cauchy sequence that is not convergent over $\mathbb{Q}$ is of course much harder, and I couldn't find an example yet (but will update the answer if I find it).
EDIT: As noticed by @Torsten Schoeneberg in comments, given the standard $p$-adic representation $\sum_{i=0}^\infty a_ip^i$ where $0\leq a_i\leq p-1$ it is known that this series converges to a rational (in $p$-adic metric) if and only if $(a_i)$ is eventually periodic (see this). Thus it is easy to construct such sequence which doesn't converge to any rational, e.g. $a_i=1$ if $i$ is a power of $2$ and $a_i=0$ otherwise.
