What Are p-adic Numbers and Why Do Mathematicians Care About Them?

Ordinary distance isn't the only way to measure how close two numbers are. Pick a prime, redefine 'close' around divisibility instead of size, and a whole parallel number system falls out, one where sums that explode in the reals settle down quietly.

By Petrus Sheya

August 7, 2026 · 6 min read

What does it mean for two numbers to be close together?

You'd probably say: subtract them, and if the result is small, they're close. 9999 and 100100 are close. 9999 and 4,000,0004{,}000{,}000 are not. That's the only rule you've ever needed, and it feels less like a rule and more like a fact about reality.

It isn't. It's a choice. And once you see the other choices available, a strange and genuinely useful number system falls right out of them.

What if "close" meant something other than "small difference"?

Here's the choice hiding inside ordinary distance: two numbers are close when their difference has a small size. Pick a prime number pp instead, and ask a completely different question: how many times does pp divide their difference? The more times pp divides aba - b, the closer we'll declare aa and bb to be, no matter how big the numbers themselves are.

Try it with p=3p = 3. Take 22 and 2929. On the real line they're pretty far apart, 2727 units. But 292=27=3329 - 2 = 27 = 3^3. That difference is divisible by 33 three whole times. Under this new rule, 22 and 2929 are actually quite close.

Drag bb below and watch the two rulers argue with each other.

Drag b and watch the two rulers disagree. The same pair of numbers can be far apart on the real line but right next to each other on the p-adic ring.

ordinary distancea = 0b = 18|b−a| = 183-adic distancefarclosea = 0b
prime p =
Real distance18
v_3(b)2
3-adic distance1/3²

Notice what's happening. The real-number ruler only cares about magnitude. The pp-adic ruler only cares about divisibility by pp. They're both legitimate ways to measure distance, and they disagree constantly. Neither one is the "real" answer. They're just different lenses.

How do you actually measure "divisible by p-ness"?

To make this rigorous we need a number that captures how divisible something is by pp. We call it the pp-adic valuation, written vp(n)v_p(n), and it's exactly what it sounds like: keep dividing nn by pp as long as it comes out even, and count how many times you managed it.

180180 with p=3p = 3: 180÷3=60180 \div 3 = 60, 60÷3=2060 \div 3 = 20, and 2020 isn't divisible by 33 anymore. Two successful divisions, so v3(180)=2v_3(180) = 2.

Once you have the valuation, the pp-adic absolute value is just:

np=pvp(n)|n|_p = p^{-v_p(n)}

A number that's divisible by pp many times gets a tiny pp-adic absolute value. A number not divisible by pp at all gets np=1|n|_p = 1, the biggest it can be. Divisibility makes numbers small in this world, not size. That flips your intuition upside down on purpose.

Pick a number, pick a prime, and watch the machine peel off factors of pp one at a time until it can't anymore.

Pick n and a prime p. The machine keeps dividing by p as long as it divides evenly. However many times it succeeds is the p-adic valuation.

farclosen180÷360÷320stops here
prime p =
v_3(n)2
Left over factor20
|n|_31/3²

Can a number have infinitely many digits... to the left?

Here's where it gets genuinely strange. In the ordinary decimal system, you can write infinitely many digits to the right of the decimal point. Think of 0.3330.333\ldots for 1/31/3. But you'd never write infinitely many digits to the left. A number like 999\ldots999 doesn't mean anything on the real line. It would have to be infinitely large.

In the pp-adic world, infinite digits to the left is exactly how you build new numbers, and they land on perfectly ordinary values.

Take p=3p = 3 and look at the string 222\ldots222, meaning "22" repeated forever to the left. Truncate it at kk digits and you get Sk=222k=3k1S_k = \underbrace{22\ldots2}_{k} = 3^k - 1 (written in base 33, that's kk copies of the digit 22). Now check what Sk+1S_k + 1 equals: it's just 3k3^k. That means SkS_k gets 33-adically closer and closer to 1-1 as kk grows, because Sk(1)=3kS_k - (-1) = 3^k, and we just showed higher powers of pp mean smaller pp-adic distance.

So 222\ldots222 (base 33) really is a legitimate way to write 1-1. Slide kk and watch the ring depth increase as more digits get added.

Slide k to reveal more digits of −1 written in base p, growing to the left forever. Each new digit drills the running total one ring closer to −1.

the p-adic digits of −1, base 322222reads right to left, just like a normal decimal, only it never ends on the leftfarclosetarget: −1Sₖ
prime p =
Truncated value Sₖ242
Sₖ + 1243 = 3
Distance to −11/3

This is the payoff of allowing infinite digits leftward: the p-adic integers aren't some abstract construction bolted onto the number line. They're what you get when you let base-p digit strings run forever in the other direction.

Watch a sum explode in one world and settle down in the other

Now for the reveal that makes all of this worth caring about. Consider the sum Sn=1+p+p2++pnS_n = 1 + p + p^2 + \cdots + p^n.

On the real number line, this is hopeless. Every term is bigger than the last, and SnS_n \to \infty. There's no sense in which this sum "converges" in the usual meaning of the word.

But look at it pp-adically. Each new term pn+1p^{n+1} you're about to add is a higher and higher power of pp, which means it's pp-adically tinier and tinier. The partial sums stop wandering and start homing in on a fixed target: 1/(p1)-1/(p-1).

Same sequence of numbers. One metric says it flies apart. The other says it converges. Press play and watch both happen at once.

Sₙ = 1 + p + p² + … + pⁿ. Watch the same growing sum blast off the real number line while it drills straight toward one fixed point p-adically.

on the real lineSₙ = 12-adicallyfarclosetarget −1/(2−1)Sₙ
prime p =
Term n0
Real value1
2-adic distance to target1/2¹

That's not a trick of notation. It's a real, useful fact: whether a sequence "converges" depends entirely on which notion of distance you're using, and the pp-adic notion makes a huge class of previously-useless sums behave.

So why do mathematicians actually care?

Because this isn't just a curiosity, it's a working tool. Equations that are hard to solve over the ordinary numbers sometimes become tractable once you check them pp-adically for every prime pp instead, an approach called the local-global principle. Number theorists use pp-adic analysis to prove statements about ordinary integers that plain real-number methods can't touch, and Andrew Wiles' proof of Fermat's Last Theorem leans on pp-adic machinery (Galois representations built over pp-adic fields) to get there. Closer to computing, the same "measure closeness by shared low-order digits" idea underlies parts of coding theory and cryptography.

None of that requires you to distrust the real numbers. It just means the real numbers were never the only sensible way to measure distance, and for certain problems, a different ruler is exactly the tool that fits.

So, what are p-adic numbers?

They're what you get when you redefine "close" around divisibility by a prime instead of size, then follow that definition all the way to its logical end: numbers with infinite digit strings extending left, sequences that converge in ways real numbers never could, and a genuinely different, self-consistent number system sitting right alongside the one you already know. The real numbers finish the rationals by filling gaps using ordinary distance. The pp-adic numbers finish the same rationals by filling gaps using a completely different notion of distance. Both are equally valid completions of the same starting set, they just look for gaps in different places.