\documentclass[numbers=enddot,12pt,final,onecolumn,notitlepage]{scrartcl}%
\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}
\usepackage[all,cmtip]{xy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{framed}
\usepackage{comment}
\usepackage{color}
\usepackage[breaklinks=True]{hyperref}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{needspace}
\usepackage{tabls}
\usepackage{tikz}
\usepackage{bbding}
%TCIDATA{OutputFilter=latex2.dll}
%TCIDATA{Version=5.50.0.2960}
%TCIDATA{LastRevised=Saturday, December 16, 2023 20:55:24}
%TCIDATA{SuppressPackageManagement}
%TCIDATA{<META NAME="GraphicsSave" CONTENT="32">}
%TCIDATA{<META NAME="SaveForMode" CONTENT="1">}
%TCIDATA{BibliographyScheme=Manual}
%TCIDATA{Language=American English}
%BeginMSIPreambleData
\providecommand{\U}[1]{\protect\rule{.1in}{.1in}}
%EndMSIPreambleData
\usetikzlibrary{arrows.meta}
\usetikzlibrary{chains}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing}
\newcounter{exer}
\newcounter{exera}
\theoremstyle{definition}
\newtheorem{theo}{Theorem}[subsection]
\newenvironment{theorem}[1][]
{\begin{theo}[#1]\begin{leftbar}}
{\end{leftbar}\end{theo}}
\newtheorem{lem}[theo]{Lemma}
\newenvironment{lemma}[1][]
{\begin{lem}[#1]\begin{leftbar}}
{\end{leftbar}\end{lem}}
\newtheorem{prop}[theo]{Proposition}
\newenvironment{proposition}[1][]
{\begin{prop}[#1]\begin{leftbar}}
{\end{leftbar}\end{prop}}
\newtheorem{defi}[theo]{Definition}
\newenvironment{definition}[1][]
{\begin{defi}[#1]\begin{leftbar}}
{\end{leftbar}\end{defi}}
\newtheorem{remk}[theo]{Remark}
\newenvironment{remark}[1][]
{\begin{remk}[#1]\begin{leftbar}}
{\end{leftbar}\end{remk}}
\newtheorem{coro}[theo]{Corollary}
\newenvironment{corollary}[1][]
{\begin{coro}[#1]\begin{leftbar}}
{\end{leftbar}\end{coro}}
\newtheorem{conv}[theo]{Convention}
\newenvironment{convention}[1][]
{\begin{conv}[#1]\begin{leftbar}}
{\end{leftbar}\end{conv}}
\newtheorem{quest}[theo]{Question}
\newenvironment{question}[1][]
{\begin{quest}[#1]\begin{leftbar}}
{\end{leftbar}\end{quest}}
\newtheorem{warn}[theo]{Warning}
\newenvironment{warning}[1][]
{\begin{warn}[#1]\begin{leftbar}}
{\end{leftbar}\end{warn}}
\newtheorem{conj}[theo]{Conjecture}
\newenvironment{conjecture}[1][]
{\begin{conj}[#1]\begin{leftbar}}
{\end{leftbar}\end{conj}}
\newtheorem{exam}[theo]{Example}
\newenvironment{example}[1][]
{\begin{exam}[#1]\begin{leftbar}}
{\end{leftbar}\end{exam}}
\newtheorem{exmp}[exer]{Exercise}
\newenvironment{exercise}[1][]
{\begin{exmp}[#1]\begin{leftbar}}
{\end{leftbar}\end{exmp}}
\newenvironment{statement}{\begin{quote}}{\end{quote}}
\newenvironment{fineprint}{\begin{small}}{\end{small}}
\iffalse
\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\newenvironment{convention}[1][Convention]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\newenvironment{question}[1][Question]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\fi
\let\sumnonlimits\sum
\let\prodnonlimits\prod
\let\cupnonlimits\bigcup
\let\capnonlimits\bigcap
\renewcommand{\sum}{\sumnonlimits\limits}
\renewcommand{\prod}{\prodnonlimits\limits}
\renewcommand{\bigcup}{\cupnonlimits\limits}
\renewcommand{\bigcap}{\capnonlimits\limits}
\newcommand\arxiv[1]{\href{http://www.arxiv.org/abs/#1}{\texttt{arXiv:#1}}}
\setlength\tablinesep{3pt}
\setlength\arraylinesep{3pt}
\setlength\extrarulesep{3pt}
\setlength\textheight{22.5cm}
\setlength\textwidth{14.8cm}
\newenvironment{verlong}{}{}
\newenvironment{vershort}{}{}
\newenvironment{noncompile}{}{}
\excludecomment{verlong}
\includecomment{vershort}
\excludecomment{noncompile}
\newcommand{\defn}[1]{{\color{darkred}\emph{#1}}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\KK}{\mathbb{K}}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\tup}[1]{\left( #1 \right)}
\newcommand{\ive}[1]{\left[ #1 \right]}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\are}{\ar@{-}}
\newcommand{\arebi}[1][]{\ar@{<-}@/_/[#1] \ar@/^/[#1]}
\newcommand{\of}{\text{ of }}
\newtheoremstyle{plainsl}
{8pt plus 2pt minus 4pt}
{8pt plus 2pt minus 4pt}
{\slshape}
{0pt}
{\bfseries}
{.}
{5pt plus 1pt minus 1pt}
{}
\theoremstyle{plainsl}
\ihead{Lecture 7, version \today}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\section*{Math 221 Winter 2023, Lecture 7: Elementary number theory}

\textbf{website:}
\texttt{\href{https://www.cip.ifi.lmu.de/~grinberg/t/23wd}{\texttt{https://www.cip.ifi.lmu.de/\symbol{126}%
grinberg/t/23wd}}}

\setcounter{section}{2}

\section{Elementary number theory}

Number theory is commonly understood to be the study of integers, and
particularly of those properties and features of integers that do not make
much sense for rational, real or complex numbers. Divisibility is one such
property; prime numbers are another. In this course, we will only cover the
very basics of elementary number theory; there is no shortage of texts that go
much deeper (some freely available ones are \cite{Stein08}, \cite{Shoup08} and
\cite{Martin17}).

\subsection{Divisibility}

\subsubsection{Definition}

We begin by defining the one most important concept in number theory:

\begin{definition}
Let $a$ and $b$ be two integers.

We write $a\mid b$ (and we say that \textquotedblleft$a$ \textbf{divides }%
$b$\textquotedblright, or \textquotedblleft$b$ is \textbf{divisible} by
$a$\textquotedblright, or \textquotedblleft$b$ is a \textbf{multiple} of
$a$\textquotedblright, or \textquotedblleft$a$ is a \textbf{divisor} of
$b$\textquotedblright; yes, all these statements are equivalent) if there
exists an integer $c$ such that $b=ac$.

We write $a\nmid b$ if we don't have $a\mid b$.
\end{definition}

\begin{example}
\textbf{(a)} We have $4\mid12$, because $12=4\cdot3$.

\textbf{(b)} We have $4\nmid11$, because there exists no integer $c$ such that
$11=4c$.

\textbf{(c)} We have $1\mid b$ for every integer $b$, since $b=1\cdot b$.

\textbf{(d)} We have $a\mid a$ for every integer $a$, since $a=a\cdot1$. In
particular, $0\mid0$, which is somewhat controversial (but true in our
opinion). (Some authors deliberately exclude $0$ as a divisor on the grounds
that $\dfrac{0}{0}$ is not well-defined, but I believe that making this an
exception is more trouble than it is worth.)

\textbf{(e)} We have $a\mid0$ for every integer $a$, since $0=a\cdot0$.

\textbf{(f)} An integer $b$ satisfies $0\mid b$ if and only if $b=0$.
\end{example}

The well-known concepts of even and odd integers are instances of divisibility:

\begin{definition}
\textbf{(a)} An integer $n$ is said to be \textbf{even} if $2\mid n$.

\textbf{(b)} An integer $n$ is said to be \textbf{odd} if $2\nmid n$.
\end{definition}

You probably know a few things about even and odd numbers already: e.g.,

\begin{enumerate}
\item The sum of two even numbers is even.

\item The sum of an even with an odd number is odd.

\item The sum of two odd numbers is even.
\end{enumerate}

Strictly speaking, these claims (particularly the third one) are not at all
obvious. So we need to understand divisibility better to even convince
ourselves that such fundamental statements are true. We will do this in
Lecture 8. First, let us prove some basic facts about divisibility.

\subsubsection{Basic properties}

In the next proposition, we shall let $\operatorname*{abs}x$ denote the
absolute value of a real number $x$. Thus,%
\[
\operatorname*{abs}x=%
\begin{cases}
x, & \text{if }x\geq0;\\
-x, & \text{if }x<0.
\end{cases}
\]
This absolute value $\operatorname*{abs}x$ is normally called $\left\vert
x\right\vert $, but I believe that writing \textquotedblleft%
$\operatorname*{abs}a\mid\operatorname*{abs}b$\textquotedblright\ is less
confusing than writing \textquotedblleft$\left\vert a\right\vert
\mid\left\vert b\right\vert $\textquotedblright\ (where four of the bars stand
for absolute values, while the middle bar stands for divisibility).

\begin{proposition}
\label{prop.div.abs}Let $a$ and $b$ be two integers. Then:

\textbf{(a)} We have $a\mid b$ if and only if $\operatorname*{abs}%
a\mid\operatorname*{abs}b$.

\textbf{(b)} If $a\mid b$ and $b\neq0$, then $\operatorname*{abs}%
a\leq\operatorname*{abs}b$.

\textbf{(c)} If $a\mid b$ and $b\mid a$, then $\operatorname*{abs}%
a=\operatorname*{abs}b$.

\textbf{(d)} Assume that $a\neq0$. Then, $a\mid b$ if and only if $\dfrac
{b}{a}\in\mathbb{Z}$.
\end{proposition}

\begin{proof}
\textbf{(a)} Proposition \ref{prop.div.abs} \textbf{(a)} says that the
divisibility $a\mid b$ does not depend on the signs of $a$ and $b$; in other
words, it says that we can replace the numbers $a$ and $b$ by their absolute
values without changing the truth (or falsity) of $a\mid b$.

Clearly, in order to prove this, it suffices to show the following two statements:

\begin{enumerate}
\item We can replace $a$ by $-a$ without changing the truth (or falsity) of
$a\mid b$;

\item We can replace $b$ by $-b$ without changing the truth (or falsity) of
$a\mid b$;
\end{enumerate}

But both of these statements are easy:

For the first statement, we assume that $a\mid b$. Thus, $b=ac$ for some
integer $c$ (by the definition of \textquotedblleft$a\mid b$\textquotedblright%
). Hence, for this integer $c$, we have $b=ac=\left(  -a\right)  \left(
-c\right)  $, which allows us to conclude that $-a\mid b$ (since $-c$ is an
integer, too). Thus, we have shown that $a\mid b$ implies $-a\mid b$.
Conversely, a similar argument shows that $-a\mid b$ implies $a\mid b$
(indeed, it is the same argument with the roles of $a$ and $-a$ swapped,
because $-\left(  -a\right)  =a$). Thus, the statements $a\mid b$ and $-a\mid
b$ are equivalent. In other words, we can replace $a$ by $-a$ without changing
the truth (or falsity) of $a\mid b$. This proves the first of our above two statements.

The proof of the second statement is similar. (This time, you need to argue
that $a\mid b$ implies $a\mid-b$. Again, write $b$ as $b=ac$, and conclude
that $-b=-ac=a\left(  -c\right)  $, so that $a\mid-b$.)

Thus, both statements are proved, so that the proof of Proposition
\ref{prop.div.abs} \textbf{(a)} is complete. \medskip

\textbf{(b)} Assume that $a\mid b$ and $b\neq0$. We must show that
$\operatorname*{abs}a\leq\operatorname*{abs}b$.

Let $x=\operatorname*{abs}a$ and $y=\operatorname*{abs}b$. Thus, $x$ is a
nonnegative integer and $y$ is a positive integer (since $b\neq0$). Thus,
$x\geq0$ and $y>0$.

Proposition \ref{prop.div.abs} \textbf{(a)} yields that $\operatorname*{abs}%
a\mid\operatorname*{abs}b$ (since $a\mid b$). In other words, $x\mid y$ (since
$x=\operatorname*{abs}a$ and $y=\operatorname*{abs}b$). In other words, $y=xz$
for some integer $z$. Consider this $z$.

If we had $z\leq0$, then we would have $y=\underbrace{x}_{\geq0}%
\ \ \underbrace{z}_{\leq0}\leq0$ (by the standard rules for inequalities),
which would contradict $y>0$. Hence, we cannot have $z\leq0$. Thus, $z>0$, so
that $z\geq1$ (since $z$ is an integer). Hence, $xz\geq x1$ (since $x\geq0$
allows us to multiply any inequality by $x$ without having to flip the sign).
Therefore, $y=xz\geq x1=x$. In other words, $x\leq y$. In other words,
$\operatorname*{abs}a\leq\operatorname*{abs}b$ (since $x=\operatorname*{abs}a$
and $y=\operatorname*{abs}b$). This proves Proposition \ref{prop.div.abs}
\textbf{(b)}. \medskip

\textbf{(c)} Let $a\mid b$ and $b\mid a$. We must prove that
$\operatorname*{abs}a=\operatorname*{abs}b$.

If $a=0$, then this is easily done (because if $a=0$, then $0=a\mid b$ quickly
leads to $b=0$, and therefore $a=0=b$, so that $\operatorname*{abs}%
a=\operatorname*{abs}b$).

Likewise, this is easily done if $b=0$.

It remains to handle the third possible case, which is when both $a$ and $b$
are $\neq0$. Consider this case. In this case, Proposition \ref{prop.div.abs}
\textbf{(b)} yields $\operatorname*{abs}a\leq\operatorname*{abs}b$ (since
$a\mid b$ and $b\neq0$). However, we can also apply Proposition
\ref{prop.div.abs} \textbf{(b)} with the roles of $a$ and $b$ interchanged
(since $b\mid a$ and $a\neq0$), and thus obtain $\operatorname*{abs}%
b\leq\operatorname*{abs}a$. Combining this with $\operatorname*{abs}%
a\leq\operatorname*{abs}b$, we find $\operatorname*{abs}a=\operatorname*{abs}%
b$. Proposition \ref{prop.div.abs} \textbf{(c)} is thus proved. \medskip

\textbf{(d)} This is quite straightforward:

Assume that $a\mid b$. Thus, there exists some integer $c$ such that $b=ac$
(by the definition of \textquotedblleft$a\mid b$\textquotedblright). This $c$
must then be $\dfrac{b}{a}$ (since $b=ac$ implies $c=\dfrac{b}{a}$ in view of
$a\neq0$). Hence, $\dfrac{b}{a}$ is an integer, i.e., we have $\dfrac{b}{a}%
\in\mathbb{Z}$.

Forget that we assumed $a\mid b$. We thus have shown that $\dfrac{b}{a}%
\in\mathbb{Z}$ if $a\mid b$. The same argument (done in reverse) yields that
conversely, if $\dfrac{b}{a}\in\mathbb{Z}$, then $a\mid b$. Combining these
two facts, we conclude that $a\mid b$ if and only if $\dfrac{b}{a}%
\in\mathbb{Z}$. This proves Proposition \ref{prop.div.abs} \textbf{(d)}.
\end{proof}

This was a warm-up (if somewhat laborious to write up). Here are some slightly
more substantial properties of divisibility:

\begin{theorem}
[rules for divisibility]\label{thm.div.rules}\textbf{(a)} We have $a\mid a$
for each $a\in\mathbb{Z}$. (This is called \textbf{reflexivity of
divisibility}.)

\textbf{(b)} If $a,b,c\in\mathbb{Z}$ satisfy $a\mid b$ and $b\mid c$, then
$a\mid c$. (This is called \textbf{transitivity of divisibility}.)

\textbf{(c)} If $a_{1},a_{2},b_{1},b_{2}\in\mathbb{Z}$ satisfy $a_{1}\mid
b_{1}$ and $a_{2}\mid b_{2}$, then $a_{1}a_{2}\mid b_{1}b_{2}$. (This is
called \textbf{multiplying two divisibilities}.)

\textbf{(d)} If $d,a,b\in\mathbb{Z}$ satisfy $d\mid a$ and $d\mid b$, then
$d\mid a+b$. (This is often restated as \textquotedblleft a sum of two
multiples of $d$ is again a multiple of $d$\textquotedblright.)
\end{theorem}

\begin{proof}
\textbf{(a)} Let $a\in\mathbb{Z}$. Then, $a=a\cdot1$, so that $a\mid a$ (since
$1$ is an integer). This proves Theorem \ref{thm.div.rules} \textbf{(a)}.
\medskip

\textbf{(b)} Let $a,b,c\in\mathbb{Z}$ satisfy $a\mid b$ and $b\mid c$.

From $a\mid b$, we see that there exists an integer $x$ such that $b=ax$.

From $b\mid c$, we see that there exists an integer $y$ such that $c=by$.

Consider these integers $x$ and $y$. Now,%
\[
c=\underbrace{b}_{=ax}y=axy.
\]
Hence, there exists some integer $z$ such that $c=az$ (namely, $z=xy$). This
shows that $a\mid c$. Theorem \ref{thm.div.rules} \textbf{(b)} is thus proven.
\medskip

\textbf{(c)} Let $a_{1},a_{2},b_{1},b_{2}\in\mathbb{Z}$ satisfy $a_{1}\mid
b_{1}$ and $a_{2}\mid b_{2}$.

From $a_{1}\mid b_{1}$, we see that $b_{1}=a_{1}c_{1}$ for some integer $c_{1}$.

From $a_{2}\mid b_{2}$, we see that $b_{2}=a_{2}c_{2}$ for some integer
$c_{2}$.

Consider these integers $c_{1}$ and $c_{2}$. Now,%
\[
\underbrace{b_{1}}_{=a_{1}c_{1}}\ \ \underbrace{b_{2}}_{=a_{2}c_{2}}%
=a_{1}c_{1}a_{2}c_{2}=\left(  a_{1}a_{2}\right)  \underbrace{\left(
c_{1}c_{2}\right)  }_{\text{an integer}}.
\]
Thus, $a_{1}a_{2}\mid b_{1}b_{2}$. This proves Theorem \ref{thm.div.rules}
\textbf{(c)}. \medskip

\textbf{(d)} Let $d,a,b\in\mathbb{Z}$ satisfy $d\mid a$ and $d\mid b$.

From $d\mid a$, we see that $a=dx$ for some integer $x$.

From $d\mid b$, we see that $b=dy$ for some integer $y$.

Consider these integers $x$ and $y$. Now,%
\[
a+b=dx+dy=d\underbrace{\left(  x+y\right)  }_{\text{an integer}}.
\]
Thus, $d\mid a+b$. This proves Theorem \ref{thm.div.rules} \textbf{(d)}.
\end{proof}

\bigskip

Theorem \ref{thm.div.rules} \textbf{(b)} tells us that divisibilities can be
chained together: If $a\mid b$ and $b\mid c$, then $a\mid c$. Therefore, you
will often see a statement of the form \textquotedblleft$a\mid b$ and $b\mid
c$\textquotedblright\ rewritten as \textquotedblleft$a\mid b\mid
c$\textquotedblright, just like two inequalities $a\leq b$ and $b\leq c$ can
be chained together to form $a\leq b\leq c$. More generally, the statement%
\[
\text{\textquotedblleft}a_{1}\mid a_{2}\mid\cdots\mid a_{k}%
\text{\textquotedblright}%
\]
shall mean that each of the numbers $a_{1},a_{2},\ldots,a_{k}$ divides the
next (i.e., that $a_{1}\mid a_{2}$ and $a_{2}\mid a_{3}$ and so on, ending
with $a_{k-1}\mid a_{k}$). By induction on $k$, it is easy to see that such a
chain of divisibilities always entails $a_{1}\mid a_{k}$.

\bigskip

How can you spot divisibilities between actual numbers? For small values of
$a$, there are several known \textbf{divisibility criteria}, which give simple
methods to check whether a given integer $b$ is divisible by $a$ (without
computing $\dfrac{b}{a}$). Here are some:

\begin{theorem}
\label{thm.div.criteria}Let $b\in\mathbb{N}$. Write $b$ in decimal notation. Then:

\textbf{(a)} We have $2\mid b$ if and only if the last digit of $b$ is $0$ or
$2$ or $4$ or $6$ or $8$.

\textbf{(b)} We have $5\mid b$ if and only if the last digit of $b$ is $0$ or
$5$.

\textbf{(c)} We have $10\mid b$ if and only if the last digit of $b$ is $0$.

\textbf{(d)} We have $3\mid b$ if and only if the sum of the digits of $b$ is
divisible by $3$.

\textbf{(e)} We have $9\mid b$ if and only if the sum of the digits of $b$ is
divisible by $9$.
\end{theorem}

\begin{example}
Let $b=10835$. Then, $2\nmid b$, since the last digit of $b$ is neither $0$
nor $2$ nor $4$ nor $6$ nor $8$ (but $5$). However, $5\mid b$, since the last
digit of $b$ is $0$ or $5$. Do we have $3\mid b$ ? The sum of the digits of
$b$ is $1+0+8+3+5=17$, which is not divisible by $3$. Thus, $b$ is not
divisible by $3$. Hence, $b$ is not divisible by $9$ either, because if we had
$9\mid b$, then we would get $3\mid9\mid b$ (by Theorem \ref{thm.div.rules}
\textbf{(b)}), which would contradict the previous sentence.
\end{example}

How do we prove Theorem \ref{thm.div.criteria}?

The easiest part is part \textbf{(c)}: If you multiply a number (written in
decimal) by $10$, then its decimal representation just grows a new digit $0$
at the end. Thus, if $10\mid b$, then the last digit of $b$ is $0$.
Conversely, if the last digit of $b$ is $0$, then $b=10b^{\prime}$, where
$b^{\prime}$ is the number $b$ with its last digit removed. For example,
$390=10\cdot39$.

Parts \textbf{(a)} and \textbf{(b)} of Theorem \ref{thm.div.criteria} are
somewhat trickier, and parts \textbf{(d)} and \textbf{(e)} more so. To get
simple proofs for these parts, we will now introduce another type of relation
between integers, known as \textbf{congruence modulo }$n$.

\subsection{Congruence modulo $n$}

\subsubsection{Definition}

\begin{definition}
Let $n,a,b\in\mathbb{Z}$. We say that $a$ is \textbf{congruent to }$b$
\textbf{modulo }$n$ if and only if $n\mid a-b$.

We shall use the notation \textquotedblleft$a\equiv b\operatorname{mod}%
n$\textquotedblright\ for \textquotedblleft$a$ is congruent to $b$ modulo
$n$\textquotedblright.

We shall use the notation \textquotedblleft$a\not \equiv b\operatorname{mod}%
n$\textquotedblright\ for \textquotedblleft$a$ is not congruent to $b$ modulo
$n$\textquotedblright.
\end{definition}

\begin{example}
\textbf{(a)} Is $3\equiv7\operatorname{mod}2$ ? This would mean that
$2\mid3-7$, which is true (since $3-7=-4=2\cdot\left(  -2\right)  $). So yes,
we do have $3\equiv7\operatorname{mod}2$.

\textbf{(b)} Is $3\equiv6\operatorname{mod}2$ ? This would mean that
$2\mid3-6$, which is false (since $3-6=-3$ is not divisible by $2$). So we
have $3\not \equiv 6\operatorname{mod}2$.

\textbf{(c)} We have $a\equiv b\operatorname{mod}1$ for any integers $a$ and
$b$. This is because $1\mid a-b$ (since $1$ divides every integer).

\textbf{(d)} Two integers $a$ and $b$ satisfy $a\equiv b\operatorname{mod}0$
if and only if $a=b$ (since $0$ divides only $0$ itself).

\textbf{(e)} For any two integers $a$ and $b$, we have $a+b\equiv
a-b\operatorname{mod}2$, since $\left(  a+b\right)  -\left(  a-b\right)  =2b$
is clearly divisible by $2$.
\end{example}

The word \textquotedblleft modulo\textquotedblright\ in the phrase
\textquotedblleft$a$ is congruent to $b$ modulo $n$\textquotedblright\ has
been invented by Gauss and should be read as something like \textquotedblleft
with respect to\textquotedblright. You can translate the statement
\textquotedblleft$a$ is congruent to $b$ modulo $n$\textquotedblright\ as
\textquotedblleft$a$ equals $b$ up to a multiple of $n$\textquotedblright.
Indeed, the definition of congruence can be restated as follows:%
\[
a\equiv b\operatorname{mod}n\ \ \ \ \ \ \ \ \ \ \text{if and only
if}\ \ \ \ \ \ \ \ \ \ a=b+nc\text{ for some }c\in\mathbb{Z}.
\]


As we will soon see, congruence modulo $2$ is essentially parity:

\begin{itemize}
\item Two even numbers are always congruent (to each other) modulo $2$.

\item Two odd numbers are always congruent (to each other) modulo $2$.

\item An even number is never congruent to an odd number modulo $2$.
\end{itemize}

We will soon prove this.

\subsubsection{Basic properties}

First, we shall prove some fundamental properties of congruence.

\begin{proposition}
\label{prop.mod.0}Let $n,a\in\mathbb{Z}$. Then, $a\equiv0\operatorname{mod}n$
if and only if $n\mid a$.
\end{proposition}

\begin{proof}
By the definition of congruence, we have the following equivalences:%
\[
\left(  a\equiv0\operatorname{mod}n\right)  \ \Longleftrightarrow\ \left(
n\mid a-0\right)  \ \Longleftrightarrow\ \left(  n\mid a\right)  .
\]
Proposition \ref{prop.mod.0} thus follows.
\end{proof}

\begin{proposition}
\label{prop.mod.rules}Let $n\in\mathbb{Z}$. Then:

\textbf{(a)} We have $a\equiv a\operatorname{mod}n$ for every $a\in\mathbb{Z}%
$. (This is called the \textbf{reflexivity of congruence}.)

\textbf{(b)} If $a,b\in\mathbb{Z}$ satisfy $a\equiv b\operatorname{mod}n$,
then $b\equiv a\operatorname{mod}n$. (This is called the \textbf{symmetry of
congruence}.)

\textbf{(c)} If $a,b,c\in\mathbb{Z}$ satisfy $a\equiv b\operatorname{mod}n$
and $b\equiv c\operatorname{mod}n$, then $a\equiv c\operatorname{mod}n$. (This
is called the \textbf{transitivity of congruence}.)

\textbf{(d)} If $a_{1},a_{2},b_{1},b_{2}\in\mathbb{Z}$ satisfy%
\[
a_{1}\equiv b_{1}\operatorname{mod}n\ \ \ \ \ \ \ \ \ \ \text{and}%
\ \ \ \ \ \ \ \ \ \ a_{2}\equiv b_{2}\operatorname{mod}n,
\]
then%
\begin{align}
a_{1}+a_{2}  &  \equiv b_{1}+b_{2}\operatorname{mod}%
n;\label{eq.prop.mod.rules.d.+}\\
a_{1}-a_{2}  &  \equiv b_{1}-b_{2}\operatorname{mod}%
n;\label{eq.prop.mod.rules.d.-}\\
a_{1}a_{2}  &  \equiv b_{1}b_{2}\operatorname{mod}n.
\label{eq.prop.mod.rules.d.*}%
\end{align}
(In other words, two congruences modulo $n$ can be added, subtracted or multiplied.)

\textbf{(e)} Let $m\in\mathbb{Z}$ be such that $m\mid n$. If $a,b\in
\mathbb{Z}$ satisfy $a\equiv b\operatorname{mod}n$, then $a\equiv
b\operatorname{mod}m$.
\end{proposition}

\begin{proof}
\textbf{(a)} Let $a\in\mathbb{Z}$. Then, $n\mid a-a$ because $a-a=0=n\cdot0$.
But this means that $a\equiv a\operatorname{mod}n$. Thus, Proposition
\ref{prop.mod.rules} \textbf{(a)} follows. \medskip

\textbf{(b)} Let $a,b\in\mathbb{Z}$ be such that $a\equiv b\operatorname{mod}%
n$. Thus, $n\mid a-b$.

We must prove that $b\equiv a\operatorname{mod}n$, i.e., that $n\mid b-a$.

However, $b-a=\left(  a-b\right)  \cdot\left(  -1\right)  $, so that $a-b\mid
b-a$. Hence, $n\mid a-b\mid b-a$. Therefore, by the transitivity of
divisibility, $n\mid b-a$. But this means precisely that $b\equiv
a\operatorname{mod}n$. Thus, Proposition \ref{prop.mod.rules} \textbf{(b)} is
proved. \medskip

\textbf{(c)} Let $a,b,c\in\mathbb{Z}$ be such that $a\equiv
b\operatorname{mod}n$ and $b\equiv c\operatorname{mod}n$.

From $a\equiv b\operatorname{mod}n$, we obtain $n\mid a-b$.

From $b\equiv c\operatorname{mod}n$, we obtain $n\mid b-c$.

Recall that a sum of two multiples of $n$ is again a multiple of $n$ (this is
Theorem \ref{thm.div.rules} \textbf{(d)}). Thus, from $n\mid a-b$ and $n\mid
b-c$, we obtain $n\mid\left(  a-b\right)  +\left(  b-c\right)  $. Since
$\left(  a-b\right)  +\left(  b-c\right)  =a-c$, we can rewrite this as $n\mid
a-c$. In other words, $a\equiv c\operatorname{mod}n$. This proves Proposition
\ref{prop.mod.rules} \textbf{(c)}. \medskip

\textbf{(d)} Let $a_{1},a_{2},b_{1},b_{2}\in\mathbb{Z}$ satisfy%
\[
a_{1}\equiv b_{1}\operatorname{mod}n\ \ \ \ \ \ \ \ \ \ \text{and}%
\ \ \ \ \ \ \ \ \ \ a_{2}\equiv b_{2}\operatorname{mod}n.
\]
Thus, $n\mid a_{1}-b_{1}$ and $n\mid a_{2}-b_{2}$.

From $n\mid a_{1}-b_{1}$, we see that $a_{1}-b_{1}=nc_{1}$ for some integer
$c_{1}$.

From $n\mid a_{2}-b_{2}$, we see that $a_{2}-b_{2}=nc_{2}$ for some integer
$c_{2}$.

Consider these integers $c_{1}$ and $c_{2}$.

From $a_{1}-b_{1}=nc_{1}$, we obtain $a_{1}=b_{1}+nc_{1}$. Similarly,
$a_{2}=b_{2}+nc_{2}$.

Adding the equalities $a_{1}=b_{1}+nc_{1}$ and $a_{2}=b_{2}+nc_{2}$ together,
we find
\[
a_{1}+a_{2}=\left(  b_{1}+nc_{1}\right)  +\left(  b_{2}+nc_{2}\right)
=b_{1}+b_{2}+n\left(  c_{1}+c_{2}\right)  .
\]
Thus, $a_{1}+a_{2}$ differs from $b_{1}+b_{2}$ by a multiple of $n$ (namely,
by $n\left(  c_{1}+c_{2}\right)  $). In other words, $n\mid\left(  a_{1}%
+a_{2}\right)  -\left(  b_{1}+b_{2}\right)  $. Hence,%
\[
a_{1}+a_{2}\equiv b_{1}+b_{2}\operatorname{mod}n.
\]


Subtracting the equalities $a_{1}=b_{1}+nc_{1}$ and $a_{2}=b_{2}+nc_{2}$ from
one another, we obtain%
\[
a_{1}-a_{2}=\left(  b_{1}+nc_{1}\right)  -\left(  b_{2}+nc_{2}\right)
=b_{1}-b_{2}+n\left(  c_{1}-c_{2}\right)  .
\]
Thus, $a_{1}-a_{2}$ differs from $b_{1}-b_{2}$ by a multiple of $n$ (namely,
by $n\left(  c_{1}-c_{2}\right)  $). Hence,%
\[
a_{1}-a_{2}\equiv b_{1}-b_{2}\operatorname{mod}n.
\]


Multiplying the equalities $a_{1}=b_{1}+nc_{1}$ and $a_{2}=b_{2}+nc_{2}$
together, we find%
\begin{align*}
a_{1}a_{2}  &  =\left(  b_{1}+nc_{1}\right)  \left(  b_{2}+nc_{2}\right)
=b_{1}b_{2}+b_{1}nc_{2}+nc_{1}b_{2}+nc_{1}nc_{2}\\
&  =b_{1}b_{2}+n\left(  b_{1}c_{2}+c_{1}b_{2}+nc_{1}c_{2}\right)  .
\end{align*}
Thus, $a_{1}a_{2}$ differs from $b_{1}b_{2}$ by a multiple of $n$ (namely, by
$n\left(  b_{1}c_{2}+c_{1}b_{2}+nc_{1}c_{2}\right)  $). Therefore,%
\[
a_{1}a_{2}\equiv b_{1}b_{2}\operatorname{mod}n.
\]
Altogether, we have proved all claims of Proposition \ref{prop.mod.rules}
\textbf{(d)} now. \medskip

\textbf{(e)} Let $m\in\mathbb{Z}$ be such that $m\mid n$. Let $a,b\in
\mathbb{Z}$ satisfy $a\equiv b\operatorname{mod}n$.

Thus, $n\mid a-b$. Hence, $m\mid n\mid a-b$, so that $m\mid a-b$ (by the
transitivity of divisibility). But this means that $a\equiv
b\operatorname{mod}m$. Thus, Proposition \ref{prop.mod.rules} \textbf{(e)} follows.
\end{proof}

\bigskip

Proposition \ref{prop.mod.rules} \textbf{(b)} says that congruences can be
turned around: From $a\equiv b\operatorname{mod}n$, we can always obtain
$b\equiv a\operatorname{mod}n$. (This is very different from divisibilities,
for which $a\mid b$ almost never implies $b\mid a$.)

Proposition \ref{prop.mod.rules} \textbf{(c)} says that congruences can be
chained together: From $a\equiv b\operatorname{mod}n$ and $b\equiv
c\operatorname{mod}n$, we can always obtain $a\equiv c\operatorname{mod}n$.
This is analogous to Theorem \ref{thm.div.rules} \textbf{(b)}, and leads to a
similar convention: Instead of writing \textquotedblleft$a\equiv
b\operatorname{mod}n$ and $b\equiv c\operatorname{mod}n$\textquotedblright, we
will often just write \textquotedblleft$a\equiv b\equiv c\operatorname{mod}%
n$\textquotedblright, understanding that (by Proposition \ref{prop.mod.rules}
\textbf{(c)}) this chain of congruences automatically implies $a\equiv
c\operatorname{mod}n$. More generally, the statement%
\[
\text{\textquotedblleft}a_{1}\equiv a_{2}\equiv\cdots\equiv a_{k}%
\operatorname{mod}n\text{\textquotedblright}%
\]
shall mean that each of the numbers $a_{1},a_{2},\ldots,a_{k}$ is congruent to
the next modulo $n$ (i.e., that $a_{i}\equiv a_{i+1}\operatorname{mod}n$ for
each $i\in\left\{  1,2,\ldots,k-1\right\}  $). By induction on $k$, it is easy
to see that such a chain of congruences always entails $a_{1}\equiv
a_{k}\operatorname{mod}n$ (and, better yet: $a_{i}\equiv a_{j}%
\operatorname{mod}n$ for all $i$ and $j$).

Note that we can only chain together two congruences modulo the same $n$, not
two congruences modulo two different $n$'s. For example, if we know that
$a\equiv b\operatorname{mod}2$ and $b\equiv c\operatorname{mod}3$, then we
cannot conclude any congruence between $a$ and $c$.

\bigskip

Proposition \ref{prop.mod.rules} \textbf{(d)} says that congruences modulo $n$
(for a fixed integer $n$) can be added, subtracted and multiplied together
(just like equalities). Before you get over-enthusiastic, keep in mind that

\begin{itemize}
\item they cannot be divided by one another: We have $2\equiv
0\operatorname{mod}2$ and $2\equiv2\operatorname{mod}2$ but $2/2\not \equiv
0/2\operatorname{mod}2$.

\item they cannot be taken to each other's power: We have $2\equiv
2\operatorname{mod}2$ and $2\equiv0\operatorname{mod}2$ but $2^{2}%
\not \equiv 2^{0}\operatorname{mod}2$.
\end{itemize}

However, we can take a congruence to a $k$-th power for a fixed $k\in
\mathbb{N}$:

\begin{exercise}
\label{exe.mod.k-th-power}Let $n,a,b\in\mathbb{Z}$ be such that $a\equiv
b\operatorname{mod}n$. Let $k\in\mathbb{N}$. Prove that $a^{k}\equiv
b^{k}\operatorname{mod}n$.
\end{exercise}

This exercise is Exercise 1 \textbf{(b)} on homework set \#3.

\bigskip

Now, let us prove Theorem \ref{thm.div.criteria} \textbf{(e)}, restating it as follows:

\begin{proposition}
Let $m\in\mathbb{N}$. Let $s$ be the sum of the digits of $m$ written in
decimal. (For instance, if $m=302$, then $s=3+0+2=5$.)

Then, $9\mid m$ if and only if $9\mid s$.
\end{proposition}

\begin{proof}
Let the integer $m$ have decimal representation $m_{d}m_{d-1}\cdots m_{0}$
(where $m_{d}$ is the leading digit). Thus,%
\begin{align*}
m  &  =m_{d}\cdot10^{d}+m_{d-1}\cdot10^{d-1}+\cdots+m_{0}\cdot10^{0}%
\ \ \ \ \ \ \ \ \ \ \text{and}\\
s  &  =m_{d}+m_{d-1}+\cdots+m_{0}.
\end{align*}


However, $10\equiv1\operatorname{mod}9$ (since $10-1=9$ is divisible by $9$).
Hence, by Exercise \ref{exe.mod.k-th-power}, we have $10^{k}\equiv
1^{k}\operatorname{mod}9$ for every $k\in\left\{  0,1,\ldots,d\right\}  $.
Multiplying this congruence with the obvious congruence $m_{k}\equiv
m_{k}\operatorname{mod}9$, we obtain\footnote{The reason why we can multiply
two congruences together is Proposition \ref{prop.mod.rules} \textbf{(d)}
(specifically, (\ref{eq.prop.mod.rules.d.*})).}%
\[
m_{k}\cdot10^{k}\equiv m_{k}\cdot1^{k}\operatorname{mod}%
9\ \ \ \ \ \ \ \ \ \ \text{for every }k\in\left\{  0,1,\ldots,d\right\}  .
\]
In other words,%
\[
m_{k}\cdot10^{k}\equiv m_{k}\operatorname{mod}9\ \ \ \ \ \ \ \ \ \ \text{for
every }k\in\left\{  0,1,\ldots,d\right\}
\]
(since $m_{k}\cdot\underbrace{1^{k}}_{=1}=m_{k}$). In other words, we have%
\begin{align*}
m_{d}\cdot10^{d} &  \equiv m_{d}\operatorname{mod}9;\\
m_{d-1}\cdot10^{d-1} &  \equiv m_{d-1}\operatorname{mod}9;\\
m_{d-2}\cdot10^{d-2} &  \equiv m_{d-2}\operatorname{mod}9;\\
&  \ldots;\\
m_{0}\cdot10^{0} &  \equiv m_{0}\operatorname{mod}9.
\end{align*}
Adding these $d+1$ many congruences together, we obtain\footnote{The reason
why we can add two congruences together is Proposition \ref{prop.mod.rules}
\textbf{(d)} (specifically, (\ref{eq.prop.mod.rules.d.+})). To be very
pedantic, we have to apply (\ref{eq.prop.mod.rules.d.+}) several times, since
we are adding not two but $d+1$ many congruences together.}%
\[
m_{d}\cdot10^{d}+m_{d-1}\cdot10^{d-1}+\cdots+m_{0}\cdot10^{0}\equiv
m_{d}+m_{d-1}+\cdots+m_{0}\operatorname{mod}9.
\]
In other words,%
\[
m\equiv s\operatorname{mod}9
\]
(since $m=m_{d}\cdot10^{d}+m_{d-1}\cdot10^{d-1}+\cdots+m_{0}\cdot10^{0}$ and
$s=m_{d}+m_{d-1}+\cdots+m_{0}$). Turning this congruence around (i.e.,
applying Proposition \ref{prop.mod.rules} \textbf{(b)}), we obtain $s\equiv
m\operatorname{mod}9$.

Now, if $9\mid m$, then $m\equiv0\operatorname{mod}9$ (by Proposition
\ref{prop.mod.0}), whence $s\equiv m\equiv0\operatorname{mod}9$ (here we are
tacitly using Proposition \ref{prop.mod.rules} \textbf{(c)}), which entails
$9\mid s$ (again by Proposition \ref{prop.mod.0}). Thus, we have shown that if
$9\mid m$, then $9\mid s$.

Conversely, if $9\mid s$, then $s\equiv0\operatorname{mod}9$ (by Proposition
\ref{prop.mod.0}), whence $m\equiv s\equiv0\operatorname{mod}9$, which in turn
entails $9\mid m$ (by Proposition \ref{prop.mod.0}). Thus, we have shown that
if $9\mid s$, then $9\mid m$.

Now we have proved that each of the statements $9\mid m$ and $9\mid s$ implies
the other. In other words, we have $9\mid m$ if and only if $9\mid s$. This
proves the proposition.
\end{proof}

In other words, Theorem \ref{thm.div.criteria} \textbf{(e)} is proven. A
similar argument (with $9$ replaced by $3$) can be used to prove Theorem
\ref{thm.div.criteria} \textbf{(d)}. In fact, $s\equiv m\operatorname{mod}9$
entails $s\equiv m\operatorname{mod}3$ by Proposition \ref{prop.mod.rules}
\textbf{(e)}, because $3\mid9$.

Parts \textbf{(a)} and \textbf{(b)} of Theorem \ref{thm.div.criteria} can be
proved along similar lines, but are in fact easier. Indeed, if $m\in
\mathbb{N}$ has decimal representation $m_{d}m_{d-1}\cdots m_{0}$, then
$m\equiv m_{0}\operatorname{mod}10$ (since the number $m-m_{0}$ has decimal
representation $m_{d}m_{d-1}\cdots m_{1}0$ and thus is divisible by $10$), and
therefore (by Proposition \ref{prop.mod.rules} \textbf{(e)}) we have $m\equiv
m_{0}\operatorname{mod}2$ and $m\equiv m_{0}\operatorname{mod}5$ as well.

\begin{thebibliography}{99999999}                                                                                         %


\bibitem[Martin17]{Martin17}%
\href{http://www2.math.ou.edu/~kmartin/intro-nt/nt.pdf}{Kimball Martin,
\textit{An (algebraic) introduction to Number Theory, Fall 2017}, December 25,
2017.}

\bibitem[Shoup08]{Shoup08}\href{https://shoup.net/ntb/}{Victor Shoup,
\textit{A Computational Introduction to Number Theory and Algebra}, 2nd
edition, Cambridge University Press 2008, with errata 2017.}

\bibitem[Stein08]{Stein08}\href{https://wstein.org/ent/ent.pdf}{William Stein,
\textit{Elementary Number Theory: Primes, Congruences, and Secrets}, Springer
2008, updated version 2017.}
\end{thebibliography}


\end{document}