Self-Squaring Numbers
Study Notes: P-adic Numbers and Their Uses
Infinite expansions and numbers that are their own squares
In an ordinary decimal expansion, digits to the right of the decimal point represent successively smaller powers of 10. A 10-adic expansion instead uses an unlimited sequence of digits extending to the left from the units digit:
Here, a0 is the units digit, a1 is the coefficient of 10, a2 is the coefficient of 102, and so on. Informally, the expansion represents
The same idea works in any base. In base p, where p is prime, the digits are 0,1,…,p−1, and an expansion represents an infinite sum of powers of p.
A striking pattern appears when repeatedly squaring numbers built from powers of 5:
52=25, which ends in 5.
252=625, which ends in 25.
6252=390625, which ends in 625.
Further squaring continues to produce longer matching endings.
The matching endings are important: each new result agrees with the previous number in more and more of its rightmost digits. This suggests constructing an infinite digit sequence by successively determining digits that make the sequence agree with its own square.
In the resulting 10-adic system, the number can satisfy
without being either 0 or 1. Such a number is an idempotent: an element unchanged by squaring. Its infinitely many digits do not represent a real number with an infinitely large magnitude. Instead, they describe a number in a different system, with a different notion of distance and convergence.
An infinite p-adic expansion is meaningful because its digits are specified consistently from the units place toward higher powers of the base. It is not interpreted using ordinary real-number size.
Arithmetic with 10-adic numbers
Addition and multiplication
Addition works digit by digit, from the units place toward the left, carrying whenever a digit sum reaches the base. For example, adding 9 and 1 gives 0 in the units place and carries 1 to the next place.
Multiplication also proceeds from the units place toward the left. The key feature is that the answer’s first few digits depend only on the first few digits of the inputs. A higher digit can be determined after enough lower-place multiplication and carrying has been completed. This means the arithmetic can be continued to determine as many digits as needed.
Fractions can appear as digit strings
Some ordinary fractions can be represented as 10-adic digit expansions, even though no division symbol is used in the expansion itself. For example, a 10-adic number can be found whose product with 7 is 1. Its digits are determined successively by working from right to left with the usual multiplication and carrying rules. It therefore represents the reciprocal of 7 in the 10-adic system.
A similar calculation finds the 10-adic representation of 31. To make a product with 3 end in 1, the units digit must be 7, because 3⋅7=21. The resulting carry is 2. At each next position, a digit of 6 works because
This produces another 0 and carries 2 again. Repeating this step gives an infinite string of 6s to the left of the final 7. Thus the 10-adic expansion with units digit 7 and all preceding digits equal to 6 represents 31.
More generally, fractions whose denominators are relatively prime to 10 have 10-adic representations. The description of “fractions” must be understood in relation to the base: not every rational number has a 10-adic integer expansion.
Negative numbers without a minus sign
An infinite string of 9s in base 10 represents −1 in the 10-adic system. Let m denote that string. Multiplying by 10 shifts the digits one place, inserting a 0 in the units place. Subtracting the shifted version from the original gives
so m=−1.
The result can also be checked directly by addition. Adding 1 to the string of all 9s makes the units digits sum to 10, producing a 0 and a carry. Every following pair of digits repeats the same process. Because there is no final leftmost digit, the carry never reaches an endpoint; every digit becomes 0. Thus the all-9 string plus 1 equals 0.
This also explains why a string of 9s followed by a units digit of 3 represents −7: it is the 10-adic form of −1+?, with the finite ending interpreted using place value and carrying.
To find the negative of a finite or infinite 10-adic digit string, one can use the 9s complement:
Replace each digit d by 9−d.
Add 1.
This is the base-10 version of the familiar complement method for representing negative integers. Subtraction can then be performed by adding the negative of the number being subtracted.
In this system, addition, subtraction, and multiplication are defined using digit operations and carrying. Fractions and negative values can be encoded by the expansions themselves, without writing a separate division or negative sign.
Why a composite base causes trouble
The 10-adic system has a significant algebraic drawback. Since 10 is composite,
two nonzero numbers can multiply to give 0 in a 10-adic system. At the units place, for instance, 5⋅4=20 ends in 0. The carries can be continued in ways that construct nonzero 10-adic numbers whose product is zero. Such elements are called zero divisors.
This creates a problem for solving equations by factoring. In ordinary arithmetic, if
then at least one of a or b must be zero. That fact lets mathematicians factor an equation and solve the smaller equations given by its factors. In a system with zero divisors, a product can be zero even when neither factor is zero.
The nontrivial idempotent arising from the repeated-squaring pattern illustrates the issue. If n2=n, then
In a number system without zero divisors, this equation forces n=0 or n=1. A 10-adic idempotent different from both values can exist precisely because the 10-adic system has zero divisors.
Prime bases and p-adic numbers
To avoid zero divisors, mathematicians use a prime base p. The resulting systems are called p-adic numbers. In base 3, for example, the only possible digits are 0, 1, and 2.
In a prime base, the product of two nonzero digits cannot be divisible by the base. For base 3, the nonzero digits are 1 and 2, and
None of these products is 0 in the units place. The same principle holds at each successive place. In a p-adic system with prime base p, a product is zero only if at least one of its factors is zero. Thus the system has no zero divisors, and the useful factorization property is restored.
A p-adic expansion has the form
where each coefficient ai is one of 0,1,…,p−1. The p-adic integers use nonnegative powers of p. The larger p-adic number system also includes fractions and numbers with negative powers of p.
In the 3-adic integers, an infinite string of 2s represents −1. Adding 1 makes the units digits sum to 3, which is 103: the units digit becomes 0 and a carry of 1 continues to the next place. This repeats indefinitely, just as the all-9 string plus 1 does in base 10.
Modular arithmetic and reading base expansions
Modular arithmetic keeps track of remainders. Working modulo m means treating numbers that differ by a multiple of m as equivalent. The remainder after division by m determines the value modulo m.
A clock illustrates arithmetic modulo 12: after 11 comes 0 again. For instance, 14 o’clock corresponds to 2 o’clock on a 12-hour clock because 14 leaves remainder 2 when divided by 12. In general,
because 36 leaves remainder 6 on division by 10, and
because 25 is a multiple of 5.
A base-3 clock has the digits 0, 1, and 2. Multiplying 2 by 2 gives 4, which is congruent to 1 modulo 3, since 4 leaves remainder 1 after division by 3.
Modular arithmetic also provides a systematic way to find the digits of a base expansion. To write 17 in base 3:
The remainder on division of 17 by 3 is 2, so the units digit is 2.
The remainder on division by 9 is 8. After accounting for the units contribution 2, the remaining amount is 6=2⋅3, so the next digit is 2.
The remainder on division by 27 is 17. The already accounted-for lower-place value is 8, leaving 9=1⋅9, so the next digit is 1.
Therefore,
Solving equations one digit at a time
The Diophantine problem
A Diophantine equation is a polynomial equation for which solutions are sought in a specified number system, often the integers or rational numbers. A well-known example is the Pythagorean equation
It has many real solutions, forming a continuous geometric set, but its integer and rational solutions are more selective. Examples of integer solutions include (3,4,5) and (5,12,13).
A more intricate example asks for three squares whose areas add to the area of a larger square, under the condition that the side length of each square is the area of the preceding one. If the first square has side length x, then the three areas are x2, x4, and x8. The condition that their total is another square is
The equation has real solutions—for example, x=1 gives y=3. But the aim is to find rational solutions, which is a much more restrictive problem.
Hensel-style expansions in powers of a prime
One approach is to seek a solution in the form of a base-3 expansion:
where each coefficient xi is 0, 1, or 2. The value y can be expanded in the same way.
Directly substituting two infinite expansions into the equation looks complicated. Modular arithmetic simplifies the work: the first coefficient is found by solving the equation modulo 3, the next by solving modulo 9, then modulo 27, and so on. Each modulus reveals one more digit.
First approximation: modulo 3
Modulo 3, every term containing a factor of 3 vanishes, so only the first coefficients matter:
The coefficient x0 can be 0, 1, or 2.
If x0=0, the left side is 0 modulo 3.
If x0=1, the three powers are all 1, so their sum is 3≡0(mod3).
If x0=2, then 22≡1(mod3), and its fourth and eighth powers are also congruent to 1. Their sum is again 3≡0(mod3).
Thus the left side is 0 for every possible x0. The only value of y0 whose square is 0 modulo 3 is y0=0. The possible first-digit pairs are therefore
The pair (0,0) gives the trivial solution x=y=0. To seek a nontrivial solution, one can continue from (x0,y0)=(1,0).
Refining the approximation: modulo 9
Set x0=1 and write
Modulo 9, all later terms vanish. Expanding the powers in the equation and reducing modulo 9 yields
If x1=1, the left side is 18, a multiple of 9. Therefore x1=1 works, and the beginning of the expansion is
At this stage, the terms involving y do not determine its next coefficient: squaring a quantity that already has a factor of 3 makes the result divisible by 9.
A further refinement: modulo 27
Now write
Using the known values x0=x1=1, expanding the equation modulo 27 reduces the condition to
Taking x2=1 makes the left side 27, so x2=1 works. Continuing with moduli 81, 243, and higher powers of 3 gives further digits. In this example, the successive coefficients are all 1, leading to the 3-adic expansion
This process of extending a solution modulo pk to a solution modulo pk+1 is an example of p-adic lifting, associated with Hensel’s method. Each stage refines the solution by one more base-p digit.
Why an apparently divergent series can have a p-adic sum
As a real-number series, the terms in
grow rather than shrink, so the partial sums do not converge to a finite real number. In the 3-adic system, however, powers of 3 become smaller in p-adic size as their exponents increase. The series therefore converges 3-adically.
The geometric-series formula gives
when the powers of r approach zero in the relevant notion of size. For the 3-adic absolute value, 3 has size 31, so the formula applies with r=3:
Thus the infinite 3-adic string of 1s represents the ordinary rational number −21 when interpreted through the 3-adic embedding of the rationals.
Substituting x=−21 into the sum-of-squares equation gives
Therefore, y=169 gives a rational solution. In the geometric interpretation, the side lengths are the magnitudes of x, x2, and x4: these are 21, 41, and 161. Their square areas add to the area of a square with side length 169.
The key point is that the same expansion can have different convergence behavior under different notions of distance. The series diverges as a real series but converges as a 3-adic series.
The p-adic notion of size and distance
Real numbers are commonly pictured on a line, where numbers are close when their difference is small in ordinary magnitude. P-adic numbers use a different geometry. Two p-adic numbers are close when their expansions agree for many initial digits, beginning at the units place.
For example, if two 3-adic expansions first differ in the coefficient of 3k, their difference is divisible by 3k. Their 3-adic distance has size
The more initial digits two numbers share, the smaller their p-adic distance. If they agree through many powers of 3, they are very close even if their ordinary real values appear far apart.
This reverses familiar intuitions about powers of 3:
In the real-number metric, higher powers such as 310 are very large.
In the 3-adic metric, a difference divisible by 310 is very small, with size 3−10.
A useful visualization is an infinite, branching tree. For 3-adic integers, the three initial branches correspond to the units digit 0, 1, or 2. Each branch then splits into three choices for the next digit, and this branching continues indefinitely. Two paths stay close together as long as they share the same initial digits; they separate at the first digit where they differ. Computing successive coefficients of a p-adic solution can therefore be understood as progressively refining the position of that solution.
The p-adic absolute value can be defined using the exponent of the largest power of p dividing a number. If vp(x) is that exponent, then for nonzero x,
For instance, a number divisible by pk has p-adic absolute value at most p−k. Greater divisibility by p means smaller p-adic size.
An absolute value is expected to satisfy three main properties:
Positive definiteness: ∣x∣≥0, and ∣x∣=0 exactly when x=0.
Multiplicativity: ∣xy∣=∣x∣∣y∣.
Triangle inequality: ∣x+y∣≤∣x∣+∣y∣.
The usual real absolute value and the p-adic absolute values satisfy these conditions. There is also the trivial absolute value, which assigns 0 to 0 and 1 to every nonzero rational number. A central result about absolute values on the rational numbers says that, up to the appropriate notion of equivalence, these are the fundamental possibilities.
Why p-adic methods help with equations
The p-adic geometry of solutions is highly disconnected compared with the continuous geometry of the real numbers. Near a proposed p-adic solution, requiring more correct digits can sharply narrow the possibilities. This makes it practical to test and refine solutions one congruence at a time.
By contrast, real polynomial equations often have large continuous sets of nearby solutions. A strategy that tries to identify one precise solution by successively fixing individual digits may be overwhelmed by the many real solutions in the surrounding space.
P-adic methods are therefore valuable not merely because they define unusual numbers, but because their arithmetic and geometry can make certain equations easier to study. They provide tools for testing whether solutions exist, constructing solutions by lifting modular approximations, and understanding equations through their behavior modulo increasing powers of primes.
Fermat’s Last Theorem and the role of p-adics
The Pythagorean equation has integer solutions, but Fermat’s Last Theorem concerns the higher-power equation
The theorem states that there are no nonzero integer solutions when n>2. Fermat famously asserted the result but did not provide a proof that was later accepted as complete. The theorem remained unproved for centuries, until Andrew Wiles, working in collaboration with Richard Taylor on part of the argument, proved it using modern mathematics that included p-adic methods.
A technique associated with the proof is called the 3–5 trick. The idea described is that an argument using the prime 3 works in many cases but can encounter an obstruction; switching to the prime 5 can then overcome that obstruction. Each prime gives its own p-adic system, with its own way of measuring size and structuring congruences.
The broader lesson is that p-adic numbers became important tools in number theory and related areas because they make prime-by-prime structure visible. They support methods that are difficult or impossible to express using only ordinary real-number intuition.
P-adic number systems and the real numbers provide different perspectives on arithmetic: the real absolute value emphasizes ordinary magnitude, while a p-adic absolute value emphasizes divisibility by a prime. Both perspectives reveal useful structure in equations.

Ask anything
We've read this whole study set, so questions about it get the best answers.