TITLE: $ab \equiv 1 \ (n)$ implies $a$ and $b$ coprime with $n$? [Proof Verification]
QUESTION [7 upvotes]: It's been a long time since I've touched anything related to elementary number theory, and I'm not convinced of my proof, which goes as follows:
Suppose that either $a$ or $b$ are not coprime with $n$. Without loss of generality, we can assume that $b$ is not coprime with $n$. Now, this implies that there exists a prime $p$ that divides both $b$ and $n$. Since $ab \equiv 1 \ (n)$, there exists $d \in \mathbb{Z}$ such that $ab = dn + 1$, and therefore 
$$
ab  \equiv dn + 1 \ (p)
$$
but since $p$ divides $b$ and $n$, we have
$$
0 \equiv 1 \ (p)
$$
which is absurd.
Thoughts?

REPLY [1 votes]: Since discussion in the comments indicates my original answer is correct, I'm copying it here to close the question.
Proof. Suppose that either $a$ or $b$ are not coprime with $n$. Without loss of generality, we can assume that $b$ is not coprime with $n$. Now, this implies that there exists a prime $p$ that divides both $b$ and $n$. Since $ab \equiv 1 \ (n)$, there exists $d \in \mathbb{Z}$ such that $ab = dn + 1$, and therefore 
$$
ab  \equiv dn + 1 \ (p)
$$
but since $p$ divides $b$ and $n$, we have
$$
0 \equiv 1 \ (p)
$$
which is absurd.
{"set_name": "stack_exchange", "score": 7, "question_id": 2705468}