← All Labs
INTERACTIVE APPLET · NUMBER THEORY · p-ADIC ANALYSIS

The p-adic / Dyadic Spectrum

Ask a strange question: how divisible is a number by 2? Not "is it even," but how many times can you halve it before hitting an odd number. That count is the 2-adic valuation \(v_2(n)\), and if you plot it for 1, 2, 3, 4, … a hauntingly regular pattern of tick-marks appears — the exact spacing of marks on a ruler, or the moves in the Tower of Hanoi. Now flip your whole idea of distance: in the p-adic world two numbers are close not when their difference is small, but when their difference is richly divisible by p. So 1 and 1025 — a thousand apart on the number line — are next-door neighbours 2-adically, because 1025 − 1 = 1024 = 2¹⁰. Drive the spectrum, then walk the p-adic tree where "near" means "shares low digits."

vₚ(n) = the exponent of the largest power of p dividing n

The valuation spectrum — a ruler drawn by divisibility

Colour each integer by how deeply p divides it · watch the self-similar tick pattern
Canvas · exact integer arithmetic

DRIVE IT

BASE p
the prime that measures divisibility
2

BASE p (prime)

HOW MANY INTEGERS

Hover or click a bar to read that integer's factorisation and its p-adic size.

WALKTHROUGH

    AHA

    RESEARCH NOTE

    The valuation. For a prime \(p\), the p-adic valuation \(v_p(n)\) is the exponent of \(p\) in the prime factorisation of \(n\) — equivalently, the number of times you can divide \(n\) by \(p\) before the result stops being an integer. So \(v_2(48)=4\) because \(48=2^4\cdot 3\), and \(v_2(\text{odd})=0\). Plotting \(v_2(1),v_2(2),v_2(3),\dots = 0,1,0,2,0,1,0,3,\dots\) reproduces the ruler sequence (OEIS A007814): the exact heights of the tick-marks on an inch ruler, and — read as "which disc moves on step \(n\)" — the optimal Tower of Hanoi solution. It is perfectly self-similar: the marks of height \(\ge k\) sit precisely at the multiples of \(p^{k}\), so magnifying the pattern by a factor of \(p\) returns the same pattern.

    A different notion of size. Define the p-adic absolute value \(|n|_p = p^{-v_p(n)}\): the more factors of \(p\) a number carries, the smaller it is. Then the p-adic distance \(d_p(a,b)=|a-b|_p\) makes two integers close exactly when \(a-b\) is a high power of \(p\). This distance is not just a curiosity — it obeys the strong triangle inequality \(|x+y|_p \le \max(|x|_p,|y|_p)\) (an ultrametric), under which every triangle is isosceles and the integers organise into an infinitely branching p-adic tree, the leaves grouped by their shared low-order base-\(p\) digits. Completing \(\mathbb{Q}\) in this metric gives the field \(\mathbb{Q}_p\) of p-adic numbers (Kurt Hensel, 1897) — a cornerstone of modern number theory, from local–global principles to Wiles' proof of Fermat's Last Theorem. Ostrowski's theorem says the ordinary absolute value and the \(p\)-adic ones are, up to equivalence, the only ways to measure the size of a rational number. Deeper reading: Gouvêa, p-adic Numbers: An Introduction; Koblitz, p-adic Numbers, p-adic Analysis, and Zeta-Functions.