Canonical P-adic Expansion of Rational is Eventually Periodic/Lemma 1

Theorem
Let $p$ be a prime number.

Let $b \in \Z_{>0}$ such that $b$ and $p$ are coprime.

Let $a \in \Z$.

Then:
 * $\forall n \in \N: \exists A_n, r_n \in \Z$
 * $(1) \quad \dfrac a b = A_n + p^{n + 1} \dfrac {r_n} b$


 * $(2) \quad 0 \le A_n \le p^{n + 1} - 1$


 * $(3) \quad \dfrac {a - \paren {p^{n + 1} - 1} b } {p^{n + 1} } \le r_n \le \dfrac a {p^{n + 1} }$

Proof
Let $n \in \N$.

From Integer Coprime to all Factors is Coprime to Whole:
 * $b, p^{n + 1}$ are coprime

From Integer Combination of Coprime Integers:
 * $\exists c_n, d_n \in \Z : c_n b + d_n p^{n + 1} = 1$

Multiplying both sides by $a$:
 * $a = a c_n b + a d_n p^{n + 1}$

Let $A_n$ be the least positive residue of $a c_n \pmod {p^{n + 1} }$.

By definition of least positive residue:
 * $0 \le A_n \le p^{n + 1} - 1$
 * $p^{n + 1} \divides \paren{a c_n - A_n}$

By definition of divisor:
 * $\exists x_n \in \Z : x_n p^{n + 1} = a c_n - A_n$

Re-arranging terms:
 * $a c_n = x_n p^{n + 1} + A_n$

We have:

Let $r_n = b x_n + a d_n$.

Then:

We have:

The result follows.