<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\section{Modular Arithmetic}

\definition{}
We say that $a, b$ are equivalent mod $m$ if $m$ divides $a - b$. \\
If $a$ is equivalent to $b$ mod $m$, we write $a \equiv b \pmod{m}$. \\
You can think of $b$ as the remainder of $a \div m$:
\begin{itemize}
	\item[] $32 \equiv 2 \pmod{6}$
	\item[] $4 \equiv 4 \pmod{6}$
	\item[] $-2 \equiv 4 \pmod{6}$
\end{itemize}

\problem{}
Complete the following:
\begin{itemize}
	\item[] $87 \equiv ? \pmod{12}$ \hspace{3em} \textcolor{gray}{(Your answer should be between $0$ and $12$)}
	\item[] $13 \equiv 2 \pmod{?}$
	\item[] $? \equiv 1 \pmod{9}$
\end{itemize}

\begin{solution}
	\begin{itemize}
		\item[] $87 \equiv 3 \pmod{12}$
		\item[] $13 \equiv 2 \pmod{11}$
		\item[] $(9k + 1) \equiv 1 \pmod{9}\ \forall k \in \mathbb{Z}$
	\end{itemize}
\end{solution}

\vfill

\definition{}
The inverse of $a$ mod $m$ is an integer $a^\star$ so that \\
$a \times a^\star \equiv 1 \pmod{m}$. \\
Note that not every $a$ has an inverse mod $m$.

\theorem{}&lt;mod_has_inverse&gt;
$a$ has an inverse mod $m$ iff $\gcd(a, m) = 1$ \\
\textcolor{gray}{\textit{The proof of this theorem is left as a challenge problem.}}

\problem{D\'ej\`a vu?}&lt;find_inverse&gt;
Find the inverse of $20 \pmod{14}$, if one exists. \\
Find the inverse of $34 \pmod{541}$, if one exists.

\begin{solution}
	$20^\star$ does not exist mod $14$, by \ref{mod_has_inverse}. \\
	$34^\star \equiv -175 \equiv 366 \pmod{541}$.
	See \ref{general_inverse} for an explanation.
\end{solution}

\vfill

\problem{}&lt;general_inverse&gt;
In general, how can we find the inverse of $a \pmod{p}$?\\
(Assume $p$ is prime.)

\begin{solution}
	We need an $a^\star$ so that $a \times a^\star \equiv 1 \pmod{m}$. \\
	This means that $aa^\star - mk = 1$. \\
	Since $p$ is prime, $\gcd(a, m) = 1$, and $aa^\star - mk = \gcd(a, m)$ \\
	Now use the Extended Euclidean Algorithm from \ref{extend_e_algorithm} to find $a^\star$.
\end{solution}

\vfill
\pagebreak

</pre></body></html>