This is a lemma from my textbook Analysis I by Amann/Escher:
Let $p$ be a prime number. Then, for each $r \in \mathbb Z$ with $0 < r < p$, there exists $m \in \mathbb Z$ such that $mr = 1 + pn$ for some $n \in \mathbb Z$.
My attempt:
By repeated use of Euclidean algorithm, there exist positive numbers $r_{0}, \ldots, r_{k}$ and $q, q_{0}, \ldots, q_{k}$ such that $r>r_{0}>r_{1}>\cdots>r_{k} \ge 0$ and
$$\begin{aligned} p &= q r &&+ r_0 \\ r &= q_0 r_0 &&+ r_1 \\ r_0 &= q_1 r_1 &&+ r_2 \\ r_k &= q_{k+1} r_{k+1} &&+ r_{k+2} \\ &\mathrel{\vdots} \\ r_{k+1} &= q_{k+2} r_{k+2} \end{aligned}$$
It follows that $r_{j}=m_{j} r+n_{j} p$ for $j=0, \ldots, k+2$ with $m_{j}, n_{j} \in \mathbb{Z}$.
We prove that $r_{k+2} = 1$. If not, $\overline p \mid r_{k+2}$ for some prime number $\overline p$. Then $\overline p \mid r_{k+1}$ and thus $\overline p \mid r_k$. By induction, $\overline p \mid r_0$ and $\overline p \mid r$. As a result, $\overline p \mid p$, which is a contradiction.
So $r_{k+2} = 1 = m_{k+2} r + n_{k+2} p$ or $m_{k+2} r = 1 + p(-n_{k+2})$.
My questions:
Does my attempt look fine or contain any logical gaps?
Is it possible to generalize this lemma to
Ver1: Let $p$ be a prime number. Then, for $r,r' \in \mathbb Z$ with $0 < r,r' <p$, there exists $m \in \mathbb Z$ such that $mr = r' + pn$ for some $n \in \mathbb Z$.
and
Ver2: Let $p$ be a positive integer. Then, for $r,r' \in \mathbb Z$ with $0 < r,r' <p$, there exists $m \in \mathbb Z$ such that $mr = r' + pn$ for some $n \in \mathbb Z$.
Thank you for your help!