Prove that for a given prime $p$ and each $0 < r < p-1$, there exists a $q$ such that
$$rq \equiv 1 \bmod p$$
I've only taken one intro number theory course (years ago), and this just popped up in a computer science class (homework). I was assuming that this proof would be elementary since my current class in an algorithm cours, but after the few basic attempts I've tried it didn't look promising. Here's a couple approaches I thought of:
(reverse engineer)
To arrive at the conclusion we would need
$$rq - 1 = kp$$
for some $k$. A little manipulation:
$$qr - kp = 1$$
That looks familiar, but I can't see anything from it.
(sum on $r$)
$$\sum_{r=1}^{p-2} r = \frac{(p-2)(p-1)}{2} = p\frac{p - 3}{2} + 1 \equiv 1 \bmod p$$
which looks good but I don't know how to incorporate $r$ int0 the final equality.
(Wilson's Theorem—proved by Lagrange)
I vaguely recall this theorem, but I was looking at it in an old book and it wasn't easy to see how we arrived there. Anyways, $p$ is prime iff $$(p-1)! \equiv -1 \bmod p$$
Here the $r$ multiplier is built in to the factorial expression so I was thinking of adding $2$ to either side
$$(p-1)! + 2 \equiv 1 \bmod p$$
which is a dead end (pretty sure). But then I was thinking, maybe multiplying Wilson't Thm by $(p+1)$? Then getting
$$(p+1)(p-1)! = -(p+1) \bmod p$$
which I think results in
$$(p+1)(p-1)! = 1 \bmod p$$
of which $r$ is a multiple and $q$ is obvious. But I'm not sure if that's valid.