Let be an integer not divisible by . Its modular inverse modulo has a unique least nonnegative representative . Reducing the inverse equation modulo shows that the representatives are compatible. Since is a p-adic unit,
so the sequence converges to the inverse in . This computes a fraction through finite integer operations.
For and , the first eight representatives are . Each satisfies . The resulting expansion is
The geometric series has ratio , whose 2-adic absolute value is , and its sum is . In the ordinary real number absolute value, the representatives grow. Different metrics impose different meanings of a good approximation. The periodic digits here are a specific instance of the rational expansions studied in Conrad's authored note.[ref]
Figure 1.
Finite modular inverses approximate one third in the 2-adic metric
. Original exact least nonnegative inverses of modulo . The left panel plots and the bound . The right plots the ordinary real error . Equal neighbouring representatives arise when the next binary digit is zero, so their exact errors also agree. Details.