Distance Measured by Divisibility
Ordinary distance on the integers records how large the difference between two numbers is. A different metric can instead record how many times a fixed prime divides that difference. Differences divisible by a large power of the prime are assigned small distances. The resulting rule is a genuine metric, and its triangle inequality is stronger than the usual one: the distance between two endpoints cannot exceed the larger of the two intervening distances.
Fix a prime number \(p\). For a nonzero integer \(n\), let \(v_p(n)\) be the largest nonnegative integer \(k\) such that \(p^k\) divides \(n\). Divisibility here applies to negative integers as well: \(p^k\) divides \(n\) when \(n=p^kq\) for some integer \(q\). The exponent \(v_p(n)\) exists. Indeed, \(p^0=1\) divides \(n\), and if \(p^k\) divides nonzero \(n\), then \(p^k\leq |n|\); only finitely many powers of \(p\geq2\) can satisfy this bound.
For a nonzero difference, the exponent is always at least zero, so \(d_p(x,y)\leq1\). A difference divisible by \(p^k\) but not by \(p^{k+1}\) has distance \(p^{-k}\). Thus, for this metric, divisibility by a higher power means closeness.
Why the Rule Is a Metric
A metric on a set \(X\) is a function \(d:X\times X\to[0,\infty)\) satisfying, for all \(x,y,z\in X\): \(d(x,y)=0\) exactly when \(x=y\); \(d(x,y)=d(y,x)\); and \(d(x,z)\leq d(x,y)+d(y,z)\). We will prove these properties and, more strongly, establish the strong triangle inequality.
Proof. The value \(d_p(x,y)\) is nonnegative: it is either zero or a positive power \(p^{-k}\). If \(x=y\), its value is zero by definition. If \(x\ne y\), then \(x-y\ne0\), so \(v_p(x-y)\) is a finite integer and \(p^{-v_p(x-y)}>0\). Therefore \(d_p(x,y)=0\) exactly when \(x=y\).
For symmetry, \(y-x=-(x-y)\). An integer divides \(x-y\) exactly when it divides its negative, so \(v_p(y-x)=v_p(x-y)\) when \(x\ne y\). When \(x=y\), both distances are zero. Hence \(d_p(x,y)=d_p(y,x)\) in all cases.
To prove the stronger inequality while including zero differences, set \(v_p(0)=\infty\) for this proof only and use \(p^{-\infty}=0\). Let \(m=\min\{v_p(x-y),v_p(y-z)\}\). If \(m\) is finite, both differences are divisible by \(p^m\). Their sum \((x-y)+(y-z)=x-z\) is therefore divisible by \(p^m\). If \(x-z\ne0\), this gives \(v_p(x-z)\geq m\), and consequently \(d_p(x,z)=p^{-v_p(x-z)}\leq p^{-m}\). If \(x-z=0\), then \(d_p(x,z)=0\leq p^{-m}\). If \(m=\infty\), both \(x-y\) and \(y-z\) are zero, so \(x=z\) and \(d_p(x,z)=0\). In every case, $$ d_p(x,z)\leq p^{-m} =\max\{p^{-v_p(x-y)},p^{-v_p(y-z)}\} =\max\{d_p(x,y),d_p(y,z)\}. $$ Since the maximum of two nonnegative numbers is at most their sum, the usual triangle inequality follows as well. Thus all metric axioms hold. \(\square\)
A metric satisfying \(d(x,z)\leq\max\{d(x,y),d(y,z)\}\) is called an ultrametric. The argument shows exactly how divisibility supplies this stronger inequality: if both successive differences have a factor \(p^m\), their sum has that factor too.
Computing with the Metric
Worked Example: Distances for the Prime 2
Use \(p=2\) to compute the three distances between \(14\), \(2\), and \(6\), then check the strong triangle inequality with endpoints \(14\) and \(6\).
For the pair \(14,2\), the difference is \(14-2=12=2^2\cdot3\). The factor \(3\) is not divisible by \(2\), so \(v_2(12)=2\), and \(d_2(14,2)=2^{-2}=1/4\).
For \(2,6\), the difference is \(2-6=-4=-(2^2)\). Its absolute value is divisible by \(2^2\), but not by \(2^3=8\), so \(v_2(-4)=2\) and \(d_2(2,6)=2^{-2}=1/4\).
For \(14,6\), the difference is \(14-6=8=2^3\). It is divisible by \(2^3\), but not by \(2^4=16\), so \(v_2(8)=3\) and \(d_2(14,6)=2^{-3}=1/8\).
Check: the strong triangle inequality gives \(d_2(14,6)\leq\max\{d_2(14,2),d_2(2,6)\}\). Substituting the computed distances gives \(1/8\leq\max\{1/4,1/4\}=1/4\), which is true. The ordinary triangle inequality also holds: \(1/8\leq1/4+1/4=1/2\).
Worked Example: A Zero Difference and Negative Differences
Use \(p=3\) to compute the distances among \(1\), \(10\), and \(19\). This example includes differences that are negative and a pair of equal distances.
The distance from \(1\) to \(10\) uses \(1-10=-9=-(3^2)\). Since \(9\) is divisible by \(3^2=9\) and not by \(3^3=27\), \(v_3(-9)=2\), so \(d_3(1,10)=3^{-2}=1/9\).
The distance from \(10\) to \(19\) uses \(10-19=-9\) again, giving \(v_3(-9)=2\) and \(d_3(10,19)=3^{-2}=1/9\).
The distance from \(1\) to \(19\) uses \(1-19=-18=-(3^2\cdot2)\). Since \(2\) is not divisible by \(3\), the highest power of \(3\) dividing \(-18\) is \(3^2\). Thus \(v_3(-18)=2\) and \(d_3(1,19)=3^{-2}=1/9\).
Check: with endpoints \(1\) and \(19\) and intermediate point \(10\), the inequality reads \(1/9\leq\max\{1/9,1/9\}=1/9\), so equality holds. Also \(d_3(10,10)=0\) by the equal-points clause in the definition; no exponent for a nonzero difference is needed.
Worked Example: The Prime Changes the Distance
Compare the distance between \(0\) and \(12\) for \(p=2\), \(p=3\), and \(p=5\).
For \(p=2\), \(12=2^2\cdot3\), with \(3\) not divisible by \(2\). Hence \(v_2(12)=2\) and \(d_2(0,12)=2^{-2}=1/4\).
For \(p=3\), \(12=3\cdot4\), with \(4\) not divisible by \(3\). Hence \(v_3(12)=1\) and \(d_3(0,12)=3^{-1}=1/3\).
For \(p=5\), \(12\) is not divisible by \(5\), while \(5^0=1\) divides every integer. Thus \(v_5(12)=0\) and \(d_5(0,12)=5^0=1\).
Check: in each case the computed distance is the defining power of its chosen prime: \(2^{-2}=1/4\), \(3^{-1}=1/3\), and \(5^0=1\). The same integer difference therefore has different distances for different choices of prime.
What the Strong Inequality Says
The proof depends on a basic divisibility fact, not on the size of the integer differences. If \(p^m\) divides each of \(x-y\) and \(y-z\), then it divides their sum \(x-z\). In distance language, if both steps have distance at most \(p^{-m}\), the direct step has distance at most \(p^{-m}\) too. This is why the maximum, rather than the sum, controls the endpoint distance.
For example, if two successive differences are both divisible by \(p^4\), then their sum is divisible by \(p^4\), even if the sum is zero or has additional factors of \(p\). The resulting endpoint distance is therefore either zero or at most \(p^{-4}\). No assumption that the three integers are distinct is needed; zero differences were included in the proof.
The prime \(p\) must be fixed when defining \(d_p\), and it must be prime as specified. For the proof of the strong inequality, the key requirement is that divisibility by \(p^m\) is preserved under addition; the metric formula and its values are then tied to the chosen prime. Changing the prime changes the function, as the calculation for \(12\) demonstrates.
A Common Mistake: Reversing the Scale
Common pitfall. The exponent is not itself the distance. For \(p=2\), the difference \(8\) has \(v_2(8)=3\). A mistaken calculation might write \(d_2(0,8)=3\), treating the exponent as the distance. The definition instead gives \(d_2(0,8)=2^{-v_2(8)}=2^{-3}=1/8\). Substitution into the formula corrects the error: a higher exponent produces a smaller positive distance, not a larger one.
There is a second useful check on the formula. If \(x\ne y\) and \(p\) does not divide \(x-y\), then \(v_p(x-y)=0\), so \(d_p(x,y)=p^0=1\). If \(p^k\) divides \(x-y\) for some \(k\geq1\), the distance is at most \(p^{-1}<1\). These conclusions follow directly from the exponent and can help detect a misplaced sign in the power.
Check Your Understanding
For each calculation, identify the prime and use the highest power dividing the stated difference.
- For \(p=2\), compute \(d_2(0,20)\), \(d_2(0,24)\), and \(d_2(20,24)\).
- For \(p=3\), find \(d_3(5,14)\) and state the exact exponent used.
- Suppose \(p^3\) divides \(x-y\) and \(p^3\) divides \(y-z\). What bound does the strong triangle inequality proof give for \(d_p(x,z)\)?
- Why does the definition assign distance zero when the two integers are equal rather than applying the exponent formula to their difference?
- Give a nonzero integer difference whose distance is \(1\) for a chosen prime \(p\), and verify the exponent.