\documentclass[12pt,letterpaper]{book}
\usepackage{times}
\usepackage{amsthm}
\usepackage{makeidx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{amsfonts}
\usepackage{hyperref}
\newcommand{\comment}[1]{}
\newtheorem{definition}{Definition}
\newtheorem{claim}{Claim}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{cor}{Corollary}
\newtheorem{def1}{Definition}
\newtheorem{Def}{Definition}
\newtheorem{prop}{Proposition}
\newtheorem{remark}{Remark}
\newtheorem{notation}{Notation}
\newtheorem{example}{Example}
\newtheorem{conjecture}{Conjecture}
\newtheorem{examples}{Examples}
\renewcommand{\chaptername}%
    {Lecture}


\linespread{1.3}
\title{Lecture notes "Analytic Number Theory"}
\author{Dr. Mohib Ali}
\date{}
\makeindex
\begin{document}
\maketitle
\begin{center}\textbf{Preface} \end{center}
These notes are prepared for the course taught at Virtual Campus of COMSATS IIT. The chapters are distributed
according to the contents of video lectures delivered. As discussed in the the first video lecture the main texts for
this course are following
\begin{itemize}
  \item[1] The Theory of Numbers by Adrew Adler and John Coury
  \item[2] Number Theory by David Burton
  \item[3] Introduction to Analytic Number Theory by Apostol
\end{itemize}

The students may consult the above mentioned texts for the course according to the following setting
\begin{itemize}
  \item Lecture 1 to Lecture 18 consult first text
  \item Lecture 19 to Lecture 24 consult second text
  \item Lecture 25 to Lecture 32 consult third text
\end{itemize} \maketitle  \tableofcontents



\chapter{Divisibility}Integers are the building blocks of the theory of
numbers. This chapter contains somewhat very simple and obvious
observations starting with properties of integers and yet the proofs
behind those observations are not as simple.

\section{Preliminaries}
We will discuss about set of integers, well ordering principal and linear combinations first.

\subsection{\textbf{The Well Ordering Principle}}

\textbf{The Well Ordering Principle:} \index{Well Ordering Principle} A least element exist in any non empty set of positive integers.\\

This principle can be taken as an axiom on integers and it will be
the key to proving many theorems.  As a result, we see that any set of
positive integers is well ordered while the set of all integers
is not well ordered.\\
\subsection{Integer Divisibility}
\index{Divisibility}
\begin{definition}
If $a$ and $b$ are integers such that $a\neq 0$, then we say "$a$
divides $b$" if there exists an integer $k$ such that $b=ka$.
\end{definition}
\index{factor} \index{Multiple} If $a$ divides $b$, we also say "$a$
is a factor of $b$" or "$b$ is a multiple of $a$" and we write
$a\mid b$. If $a$ doesn't divide $b$, we write $a\nmid b$. For
example $2\mid 4$ and $7\mid 63$, while $5\nmid 26$.

\begin{example}
a) Note that any even integer has the form $2k$ for some integer $k$, while any odd integer has the form $2k+1$ for some integer $k$. Thus $2|n$ if $n$ is even,
while $2\nmid n$ if $n$ is odd.\\
b) $\forall a\in\mathbb{Z}$ one has that $a\mid 0$.\\
c) If $b\in\mathbb{Z}$ is such that $|b|<a$, and $b\neq 0$, then $a\nmid b$.
\end{example}

\begin{theorem}
If $a, b$ and $c$ are integers such that $a\mid b$ and $b\mid c$,
then $a\mid c$.
\end{theorem}

\begin{proof}
Since $a\mid b$ and $b\mid c$, then there exist integers $k_1$ and
$k_2$ such that $b=k_1a$ and $c=k_2b$.  As a result, we have
$c=k_1k_2a$ and hence $a\mid c$.
\end{proof}

\begin{example}
Since $6\mid 18$ and $18\mid 36$, then $6\mid 36$.
\end{example}

The following theorem states that if an integer divides two other
integers then it divides any linear combination of these integers.

\begin{theorem}\label{thm4}
If $a,b,c,m$ and $n$ are integers, and if $c\mid a$ and $c\mid b$,
then $c\mid (ma+nb)$.
\end{theorem}

\begin{proof}
Since $c\mid a$ and $c\mid b$, then by definition there exists $k_1$
and $k_2$ such that $a=k_1c$ and $b=k_2c$. Thus
\begin{equation*}
ma+nb=mk_1c+nk_2c=c(mk_1+nk_2),
\end{equation*}
and hence $c\mid (ma+nb)$.
\end{proof}

Theorem \ref{thm4} can be generalized to any finite linear combination as follows. If\\
\begin{equation*}
a\mid b_1, a\mid b_2,...,a\mid b_n
\end{equation*}
then
\begin{equation}
a\mid \sum_{j=1}^nk_jb_j
\end{equation}
for any set of integers $k_1,\cdots,k_n\in\mathbb{Z}$. It would be a
nice exercise to prove the generalization by induction.

\subsection{The Division Algorithm}

\par The following theorem states somewhat an elementary but very useful
result.

\begin{theorem}\label{thm5}\textbf{The Division Algorithm} \index{Division Algorithm} If $a$ and $b$ are
integers such that $b>0$, then there exist unique integers $q$ and
$r$ such that $a=bq+r$ where $0\leq r< b$.
\end{theorem}

\begin{proof}
Consider the set $A=\{a-bk\geq 0 \mid k\in \mathbb{Z}\}$.  Note that
$A$ is nonempty since for $k<a/b$, $a-bk>0$.  By the well ordering
principle, $A$ has a least element $r=a-bq$ for some $q$. Notice
that $r\geq 0$ by construction.  Now if  $r\geq b$ then (since
$b>0$)
\begin{equation*}
r>r-b=a-bq-b=a-b(q+1)=\geq 0.
\end{equation*}
This leads to a contradiction since $r$ is assumed to be the least
positive integer of the form $r=a-bq$.  As a result we have $0\leq r
<b$.
\par We will show that $q$ and $r$ are unique.  Suppose
that $a=bq_1+r_1$ and $a=bq_2+r_2$ with $0\leq r_1<b$ and $0\leq
r_2<b$.  Then we have
\begin{equation*}
b(q_1-q_2)+(r_1-r_2)=0.
\end{equation*}
As a result we have
\begin{equation*}
b(q_1-q_2)=r_2-r_1.
\end{equation*}
Thus we get that
\begin{equation*}
b\mid (r_2-r_1).
\end{equation*}
And since $-\max(r_1,r_2)\leq|r_2-r_1|\leq\max(r_1,r_2)$, and $b>\max(r_1,r_2)$,
then $r_2-r_1$ must be $0$, i.e. $r_2=r_1$. And since
$bq_1+r_1=bq_2+r_2$, we also get that $q_1=q_2$. This proves uniqueness.
\end{proof}

\begin{example}
If $a=71$ and $b=6$, then $71=6\cdot 11+5$.  Here $q=11$ and $r=5$.
\end{example}

\textbf{Exercises}
\begin{enumerate}
\item{Show that $5\mid 25, 19\mid38$ and $2\mid 98$.}\item{Use the
division algorithm to find the quotient and the remainder when 76 is
divided by 13}. \item{Use the division algorithm to find the
quotient and the remainder when -100 is divided by 13.}\item{Show
that if $a,b,c$ and $d$ are integers with $a$ and $c$ nonzero, such
that $a\mid b$ and $c\mid d$, then $ac\mid bd$.}\item{Show that if
$a$ and $b$ are positive integers and $a\mid b$, then $a\leq
b$.}\item{Prove that the sum of two even integers is even, the sum
of two odd integers is even and the sum of an even integer and an
odd integer is odd.}\item{Show that the product of two even integers
is even, the product of two odd integers is odd and the product of
an even integer and an odd integer is even.} \item{Show that if $m$
is an integer then $3$ divides $m^3-m$.} \item{Show that the square
of every odd integer is of the form $8m+1$.}\item{Show that the
square of any integer is of the form $3m$ or $3m+1$ but not of the
form $3m+2$.}\item{Show that if $ac\mid bc$, then $a\mid
b$.}\item{Show that if $a\mid b$ and $b\mid a$ then $a=\pm b$.}
\end{enumerate}


\section{The Greatest Common Divisor}
\par  In this section we define the greatest
common divisor (gcd) \index{Greatest Common Divisor} of two integers
and discuss its properties. We also prove that the greatest common
divisor of two integers is a linear combination of these integers.

Two integers $a$ and $b$, not both $0$, can have only finitely many
divisors, and thus can have only finitely many common divisors. In
this section, we are interested in the greatest common divisor of
$a$ and $b$. Note that the divisors of $a$ and that of $\mid a \mid
$ are the same.

\begin{definition}
The greatest common divisor of two integers $a$ and $b$ is the
greatest integer that divides both $a$ and $b$.
\end{definition}

We denote the greatest common divisor of two integers $a$ and $b$ by
$(a,b)$.  We also define $(0,0)=0$.

\begin{example}
Note that the greatest common divisor of 24 and 18 is 6.  In other
words $(24,18)=6$.
\end{example}

There are couples of integers (e.g. 3 and 4, etc...) whose greatest
common divisor is 1 so we call such integers relatively prime
integers.\index{Relatively Prime}

\begin{definition}
Two integers $a$ and $b$ are relatively prime if $(a,b)=1$.
\end{definition}

\begin{example}
The greatest common divisor of 9 and 16 is 1, thus they are
relatively prime.
\end{example}

Note that every integer has positive and negative divisors.  If
$a$ is a positive divisor of $m$, then $-a$ is also a divisor of
$m$.  Therefore by our definition of the greatest common divisor, we
can see that $(a,b)=(\mid a\mid, \mid b\mid)$.

\par We now present a theorem about the greatest common divisor of
two integers.  The theorem states that if we divide two integers by
their greatest common divisor, then the outcome is a couple of integers that are relatively prime.

\begin{theorem}
If $(a,b)=d$ then $(a/d,b/d)=1$.
\end{theorem}

\begin{proof}
We will show that $a/d$ and $b/d$ have no common positive divisors
other than $1$.  Assume that $k$ is a positive common divisor such
that $k\mid a/d$ and $k\mid b/d$.  As a result, there are two
positive integers $m$ and $n$ such that
\begin{equation*}
a/d=km \hspace{0.3 cm}\mbox{and} \ \  b/d=kn
\end{equation*}
Thus we get that
\begin{equation*}
a=kmd \hspace{0.3 cm}\mbox{and} \ \  b=knd.
\end{equation*}
Hence $kd$ is a common divisor of both $a$ and $b$.  Also,
$kd\geq d$. However, $d$ is the greatest common divisor of $a$ and
$b$.  As a result, we get that $k=1$.
\end{proof}

The next theorem shows that the greatest common divisor of two
integers does not change when we add a multiple of one of the
two integers to the other.

\begin{theorem}
Let $a,b$ and $c$ be integers.  Then $(a,b)=(a+cb,b)$.
\end{theorem}

\begin{proof}
We will show that every divisor of $a$ and $b$ is also a divisor of
$a+cb$ and $b$ and vise versa.  Hence they have exactly the same
divisors.  So we get that the greatest common divisor of $a$ and $b$
will also be the greatest common divisor of $a+cb$ and $b$. Let $k$
be a common divisor of $a$ and $b$. By Theorem \ref{thm4},  $k \mid
(a+cb)$ and hence $k$ is a divisor of $a+cb$.  Now assume that $l$
is a common divisor of $a+cb$ and $b$. Also by Theorem \ref{thm4} we
have ,
\begin{equation*}
l\mid ((a+cb)-cb)=a.
\end{equation*}
As a result, $l$ is a common divisor of $a$ and $b$ and the result
follows.
\end{proof}

\begin{example}
Notice that $(4,14)=(4,14-3\cdot 4)=(4,2)=2$.
\end{example}

We now present a theorem which proves that the greatest common
divisor of two integers can be written as a linear combination of
the two integers.

\begin{theorem}\label{thm9}
The greatest common divisor of two integers $a$ and $b$, not both
$0$ is the least positive integer such that $ma+nb=d$ for some
integers $m$ and $n$.
\end{theorem}

\begin{proof}  Assume without loss of generality that $a$ and $b$ are positive integers.
Consider the set of all positive integer linear combinations of $a$
and $b$. This set is non empty since $a=1\cdot a+0\cdot b$ and $b=0\cdot a+1\cdot b$ are both
in this set. Thus this set has a least element $d$ by the
well-ordering principle. Thus $d=ma+nb$ for some integers $m$ and
$n$.  We have to prove that $d$ divides both $a$ and $b$ and that it
is the greatest divisor of $a$ and $b$.
\par By the division algorithm, we have
\begin{equation*}
a=dq+r, \ \ \ 0\leq r<d.
\end{equation*}
Thus we have
\begin{equation*}
r=a-dq=a-q(ma+nb)=(1-qm)a-qnb.
\end{equation*}
We then have that $r$  is a linear combination of $a$ and $b$. Since
$0\leq r<d$ and $d$ is the least positive integer which is a linear
combination of $a$ and $b$, then $r=0$ and $a=dq$.  Hence $d\mid
a$.  Similarly $d\mid b$.  Now notice that if there is a divisor $c$
that divides both $a$ and $b$.  Then $c$ divides any linear
combination of $a$ and $b$ by Theorem 4.  Hence $c\mid d$. This
proves that any common divisor of $a$ and $b$ divides $d$. Hence
$c\leq d$, and $d$ is the greatest divisor.
\end{proof}

As a result, we conclude that if $(a,b)=1$ then there exist integers
$m$ and $n$ such that $ma+nb=1$.


\begin{definition}
Let $a_1,a_2,...,a_n$ be integers, not all $0$.  The greatest common
divisor of these integers is the largest integer that divides all of
the integers in the set.  The greatest common divisor of
$a_1,a_2,...,a_n$ is denoted by      $(a_1,a_2,...,a_n)$.
\end{definition}
\index{Mutually Relatively Prime}
\begin{definition}
The integers $a_1,a_2,...,a_n$ are said to be mutually relatively
prime if $(a_1,a_2,...,a_n)=1$.
\end{definition}

\begin{example}
The integers $3, 6, 7$ are mutually relatively prime since
$(3,6,7)=1$ although $(3,6)=3$.
\end{example}
\index{Pairwise Prime}
\begin{definition}
The integers $a_1,a_2,...,a_n$ are called pairwise prime
if for each $i\neq j$, we have $(a_i,a_j)=1$.
\end{definition}

\begin{example}
The integers $3,14,25$ are pairwise relatively prime.  Notice also
that these integers are mutually relatively prime.
\end{example}

\par Notice that if $a_1,a_2,...,a_n$ are pairwise relatively prime then they are mutually relatively prime.
\\
\\
\\
\\
\textbf{Exercises}
\begin{enumerate}
\item{Find the greatest common divisor of 15 and 35.} \item{Find
the greatest common divisor of 100 and 104.} \item{Find the greatest
common divisor of -30 and 95.}\item{Let $m$ be a positive integer.
Find the greatest common divisor of $m$ and $m+1$.}\item{Let $m$ be
a positive integer, find the greatest common divisor of $m$ and
$m+2$.} \item{Show that if $m$ and $n$ are integers such that
$(m,n)=1$, then (m+n,m-n)=1 or 2.}\item{Show that if $m$ is a
positive integer, then $3m+2$ and $5m+3$ are relatively
prime.}\item{Show that if $a$ and $b$ are relatively prime integers,
then $(a+2b,2a+b)=1$or $3$.} \item{Show that if $a_1,a_2,...,a_n$
are integers that are not all 0 and $c$ is a positive integer, then
$(ca_1,ca_2,...,ca_n)=c(a_1,a_2,...a_n).$}
\end{enumerate}
\section{Least Common Multiple}
We can use prime factorization to find the smallest common multiple
of two positive integers.

\begin{definition}
The least common multiple (l.c.m.) of two positive integers is the
smallest positive integer that is a multiple of both.
\end{definition}

We denote the least common multiple of two positive integers $a$ an
$b$ by $\langle a,b\rangle$.

\begin{example}
$\langle2,8\rangle=8$, $\langle5,8\rangle=40$
\end{example}

We can figure out $\langle a,b\rangle$ once we have the prime
factorization of $a$ and $b$.  To do that, let
\begin{equation*}
a=p_1^{a_1}p_2^{a_2}...p_m^{a_n}  \hspace{0.2cm}\mbox{and}\ \
b=p_1^{b_1}p_2^{b_2}...p_m^{b_n},
\end{equation*}
where (as above) we exclude any prime with 0 power in both $a$ and $b$. Then $\langle
a,b\rangle=p_1^{\max(a_1,b_1)}p_2^{\max(a_2,b_2)}...p_m^{\max(a_n,b_n)}$,
where $\max(a,b)$ is the maximum of the two integers $a$ and $b$. We
now prove a theorem that relates the least common multiple of two
positive integers to their greatest common divisor.  In some books,
this theorem is adopted as the definition of the least common
multiple.  To prove the theorem we present a lemma

\begin{lemma}
If a and b are two real numbers, then
\begin{equation*}
\min(a,b)+\max(a,b)=a+b
\end{equation*}
\end{lemma}

\begin{proof}
Assume without loss of generality that $a\geq b$.  Then
\begin{equation*}
\max(a,b)=a \hspace{0.2cm}\mbox{and} \ \  \min(a,b)=b,
\end{equation*}
and the result follows.
\end{proof}

\begin{theorem}
Let $a$ and $b$ be two positive integers.  Then
\begin{enumerate}
 \item {$\langle a,b\rangle\geq 0$};
 \item {$\langle a,b \rangle=ab/(a,b)$};
\item{If $a\mid m$ and $b \mid m$, then $\langle a,b \rangle \mid
m$}
\end{enumerate}
\end{theorem}

\begin{proof}
The proof of part 1 follows from the definition.  \\
As for part 2, let
\begin{equation*}
a=p_1^{a_1}p_2^{a_2}...p_m^{a_n} \mbox{and} \ \
b=p_1^{b_1}p_2^{b_2}...p_m^{b_n}.
\end{equation*}
Notice that since
\begin{equation*}
(a,b)=p_1^{\min(a_1,b_2)}p_2^{\min(a_2,b_2)}...p_n^{\min(a_n,b_n)}
\end{equation*}
and
\begin{equation*}
\langle
a,b\rangle=p_1^{\max(a_1,b_1)}p_2^{\max(a_2,b_2)}...p_m^{\max(a_n,b_n)},
\end{equation*}
then
\begin{eqnarray*}
\langle a,b
\rangle(a,b)&=&p_1^{\max(a_1,b_1)}p_2^{\max(a_2,b_2)}...p_m^{\max(a_n,b_n)}
p_1^{\min(a_1,b_2)}p_2^{min(a_2,b_2)}...p_n^{\min(a_n,b_n)}\\ &=&
p_1^{\max(a_1,b_1)+\min(a_1,b_1)}p_2^{\max(a_2,b_2)+\min(a_2,b_2)}...p_m^{\max(a_n,b_n)+\min(a_n,b_n)}\\&=&
p_1^{a_1+b_1}p_2^{a_2+b_2}...p_n^{(a_n+b_n)}\\&=&p_1^{a_1}p_2^{a_2}...p_m^{a_n}p_1^{b_1}p_2^{b_2}...p_m^{b_n}=ab
\end{eqnarray*}
Note also that we used Lemma 8 in the above equations.  For part
3, it would be a nice exercise to show that $ab/(a,b) \mid m$
(Exercise 6). Thus $\langle a,b \rangle \mid m$.
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Find the least common multiple of 14 and 15.}\item{Find the
least common multiple of 240 and 610.}\item{Find the least common
multiple and the greatest common divisor of $2^55^67^211$ and
$2^35^87^213$.}\item{Show that every common multiple of two positive
integers $a$ and $b$ is divisible by the least common multiple of
$a$ and $b$.}\item{Show that if $a$ and $b$ are positive integers
then the greatest common divisor of $a$ and $b$ divides their least
common multiple.  When are the least common multiple and the
greatest common divisor equal to each other.}
\item{Show that $ab/(a,b) \mid m$ where $m=<a,b>$.}
\end{enumerate}


\chapter{Fundamental Theorem of Arithmetics}Prime numbers, the building blocks of integers, have been studied
extensively over the centuries.  Being able to present an integer
uniquely as product of primes is the main reason behind the whole
theory of numbers and behind the interesting results in this theory.
Many interesting theorems, applications and conjectures have been
formulated based on the properties of prime numbers.
\par In this chapter, we present methods to determine whether a number
is prime or composite using an ancient Greek method invented by
Eratosthenes.  We also show that there are infinitely many prime
numbers. We then proceed to show that every integer can be written
uniquely as a product of primes.  \par We introduce as well the
concept of diophantine equations where integer solutions from given
equations are determined using the greatest common divisor. We then
mention the Prime Number theorem without giving a proof of course in
addition to other conjectures and major results related to prime
numbers.





\section{The infinitude of Primes}
We now show that there are infinitely many primes.  There are
several ways to prove this result.  An alternative proof to the one
presented here is given as an exercise.  The proof we will provide
was presented by Euclid in his book the Elements.

\begin{theorem}
There are infinitely many primes.
\end{theorem}

\begin{proof}
We present the proof by contradiction.  Suppose there are finitely
many primes $p_1, p_2, ...,p_n$, where $n$ is a positive integer.
Consider the integer $Q$ such that
\begin{equation*}
Q=p_1p_2...p_n+1.
\end{equation*}
By Lemma 3, $Q$ has at least a prime divisor, say $q$.  If we prove
that $q$ is not one of the primes listed then we obtain a
contradiction.  Suppose now that $q=p_i$ for $1\leq i\leq n$. Thus
$q$ divides $p_1p_2...p_n$ and as a result $q$ divides
$Q-p_1p_2...p_n$.  Therefore $q$ divides 1.  But this is impossible
since there is no prime that divides 1 and as a result $q$ is not
one of the primes listed.
\end{proof}
The following theorem discusses the large gaps between primes.  It
simply states that there are arbitrary large gaps in the series of
primes and that the primes are spaced irregularly.

\begin{theorem}
Given any positive integer $n$, there exists $n$ consecutive
composite integers.
\end{theorem}

\begin{proof}
Consider the sequence of integers
\begin{equation*}
(n+1)!+2, (n+1)!+3,...,(n+1)!+n, (n+1)!+n+1
\end{equation*}
Notice that every integer in the above sequence is composite because
$k$ divides $(n+1)!+k$ if $2\leq k\leq n+1$ by \ref{thm4}.
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Show that the integer $Q_n=n!+1$, where $n$ is a positive
integer, has a prime divisor greater than $n$.  Conclude that there
are infinitely many primes.  Notice that this exercise is another
proof of the infinitude of primes.} \item{Find the smallest five
consecutive composite integers.}\item{Find one million consecutive
composite integers.}\item{Show that there are no prime triplets
other than 3,5,7.}
\end{enumerate}


\section{The Fundamental Theorem of Arithmetic}
The Fundamental Theorem of Arithmetic is one of the most important
results in this chapter. It simply says that every positive integer
can be written uniquely as a product of primes.  The unique
factorization is needed to establish much of what comes later. There
are systems where unique factorization fails to hold.  Many of these
examples come from algebraic number theory.  We can actually list an
easy example where unique factorization fails.
\par Consider the class $C$ of positive even integers.  Note that $C$ is closed under multiplication,
which means that the product of any two elements in $C$ is again in $C$.
Suppose now that  the only number we know are the members of $C$.
Then we have $12=2.6$ is composite where as $14$ is prime since it is not the product of two numbers in $C$.
Now notice that $60=2.30=6.10$ and thus the factorization is not unique.
\par We now give examples of the unique factorization of integers.
\index{Factorization}
\begin{example}
$99=3\cdot 3\cdot 11=3^2\cdot 11$, \ \ \ $32=2\cdot 2\cdot 2\cdot 2\cdot 2=2^5$
\end{example}

\subsection{The Fundamental Theorem of Arithmetic}
To prove the fundamental theorem of arithmetic, we need to prove
some lemmas about divisibility.

\begin{lemma}\label{lemma4}
If a,b,c are positive integers such that $(a,b)=1$ and $a \mid bc$,
then $a\mid c$.
\end{lemma}

\begin{proof}
Since $(a,b)=1$, then there exists integers $x,y$ such that
$ax+by=1$. As a result, $cax+cby=c$.  Notice that since $a \mid bc$,
then by Theorem 4,  $a$ divides $cax+cby$ and hence $a$ divides $c$.
\end{proof}

We can generalize the above lemma as such: If $(a_,n_i)=1$ for every
$i=1,2,\cdots,n$ and $a\mid n_1n_2\cdots n_{k+1}$, then $a\mid
n_{k+1}$. We next prove a case of this generalization and use this
to prove the fundamental theorem of arithmetic.

\begin{lemma}\label{lemma5}
If $p$ divides $n_1n_2n_3...n_k$, where p is a prime and $n_i >0$
for all $1\leq i\leq k$, then there is an integer $j$ with $1\leq
j\leq k$ such that $p \mid n_j$.
\end{lemma}

\begin{proof}
We present the proof of this result by induction.  For $k=1$, the
result is trivial.  Assume now that the result is true for $k$.
Consider $n_1n_2...n_{k+1}$ that is divisible by $p$.  Notice that
either
\begin{equation*}
(p,n_1n_2...n_k)=1\ \  \mbox{or}  \ \ (p,n_1n_2...n_{k})=p.
\end{equation*}
Now if $(p,n_1n_2...n_k)=1$ then by Lemma 4, $p \mid n_{k+1}$. Now
if $p\mid n_1n_2...n_k$, then by the induction hypothesis, there
exists an integer $i$ such that $p\mid n_i$.
\end{proof}

We now state the fundamental theorem of arithmetic and present the
proof using Lemma 5. \index{Fundamental Theorem of Arithmetic}
\begin{theorem}\label{fta}
\textbf{The Fundamental Theorem of Arithmetic}  Every positive
integer different from 1 can be written uniquely as a product of
primes.
\end{theorem}

\begin{proof}
If $n$ is a prime integer, then $n$ itself stands as a product of
primes with a single factor.  If $n$ is composite, we use proof by
contradiction.  Suppose now that there is some positive integer that
cannot be written as the product of primes.  Let $n$ be the smallest
such integer.  Let $n=ab$, with $1<a<n$ and $1<b<n$.  As a result
$a$ and $b$ are products of primes since both integers are less than
$n$.  As a result, $n=ab$ is a product of primes, contradicting that it is not. This shows that
every integer can be written as product of primes. We now prove that
the representation of a positive integer as a product of primes is
unique.  Suppose now that there is an integer $n$ with two different
factorizations say
\begin{equation*}
n=p_1p_2...p_s=q_1q_2...q_r
\end{equation*}
where $p_1,p_2,...p_s,q_1,q_2,...q_r$ are primes,
\begin{equation*}
 p_1\leq p_2 \leq
p_3\leq ...\leq p_s \mbox{and} \ \  q_1 \leq q_2 \leq q_3 \leq ...
\leq q_r.
\end{equation*}
Cancel out all common primes from the factorizations above to get
\begin{equation*}
p_{j_1}p_{j_2}...p_{j_u}=q_{i_1}q_{i_2}...q_{i_v}
\end{equation*}
Thus all the primes on the left side are different from the primes
on the right side. Since any $p_{j_l}$ $(l=1,\cdots,n)$ divides $p_{j_1}p_{j_2}...p_{j_u}$,
then $p_{j_l}$ must divide $q_{i_1}q_{i_2}...q_{i_v}$, and hence by Lemma 5, $p_{j_1}$ must divide $q_{j_k}$ for
some $1\leq k \leq v$ which is impossible.  Hence the representation
is unique.
\end{proof}

\begin{remark}\label{remark1}
The unique representation of a positive integer $n$ as a product of
primes can be written in several ways.  We will present the most
common representations. For example, $n=p_1p_2p_3...p_k$ where $p_i$
for $1\leq i\leq k$ are not necessarily distinct. Another example
would be
\begin{equation}
n=p_1^{a_1}p_2^{a_2}p_3^{a_3}...p_j^{a_j}
\end{equation}
where all the
$p_i$ are distinct for $1\leq i\leq j$. One can also write a formal product
\begin{equation}
n=\prod_{all\hspace{0.1cm} primes\hspace{0.1cm} p_i}p_i^{\alpha_i},
\end{equation}
where all but finitely many of the $\alpha_i's$ are 0.
\end{remark}


\begin{example}
The prime factorization of 120 is given by $120=2\cdot 2\cdot 2\cdot
3\cdot 5=2^3\cdot 3\cdot 5$. Notice that 120 is written in the two
ways described in \ref{remark1}.
\end{example}


\chapter{Euclidean Algorithm}\section{The Euclidean Algorithm} \index{Euclidean Algorithm}
In this section we describe a systematic method that determines the
greatest common divisor of two integers. This method is called the
Euclidean algorithm.
\begin{lemma}\label{lem1}
If $a$ and $b$ are two integers and $a=bq+r$ where also $q$ and $r$
are integers, then $(a,b)=(r,b)$.
\end{lemma}

\begin{proof}
Note that by theorem 8, we have $(bq+r,b)=(b,r)$.
\end{proof}
The above lemma will lead to a more general version of it.  We now
present the Euclidean algorithm in its general form.  It states that
the greatest common divisor of two integers is the last non zero
remainder of the successive division. \index{Division Algorithm}
\begin{theorem}
Let $a=r_0$ and $b=r_1$ be two positive integers where $a\geq b$. If
we apply the division algorithm successively to obtain that
\begin{equation*}
r_j=r_{j+1}q_{j+1}+r_{j+2} \ \ \mbox{where} \ \  0\leq
r_{j+2}<r_{j+1}
\end{equation*}
for all $j=0,1,...,n-2$ and
\begin{equation*}
r_{n+1}=0.
\end{equation*}
Then $(a,b)=r_{n}$.
\end{theorem}

\begin{proof}
By applying the division algorithm, we see that
\begin{eqnarray*}
r_0&=&r_1q_1+r_2 \ \ \ \ \ 0\leq r_2<r_1, \\
r_1&=&r_2q_2+r_3 \ \ \ \ \ 0\leq r_3<r_2, \\
 &.&    \\
 &.&    \\
&.&    \\
r_{n-2}&=&r_{n-1}q_{n-1}+r_{n} \ \ \ \ \ 0\leq r_{n}<r_{n-1}, \\
r_{n-1}&=&r_{n}q_{n}.
\end{eqnarray*}
Notice that, we will have a remainder of $0$ eventually since all
the remainders are integers and every remainder in the next step is
less than the remainder in the previous one.  By Lemma \ref{lem1},
we see that
\begin{equation*}
(a,b)=(b,r_2)=(r_2,r_3)=...=(r_n,0)=r_n.
\end{equation*}
\end{proof}

\begin{example}
We will find the greatest common divisor of $4147$ and $10672$:\\
\end{example}
Note that
\begin{eqnarray*}
 10672&=&4147\cdot 2+2378,\\
 4147&=&2378\cdot 1+1769,\\
2378&=&1769\cdot 1+609,\\
1769&=&609\cdot 2 +551,\\
609&=& 551\cdot 1+58, \\
551&=&58\cdot 9+ 29,\\
 58&=&29\cdot 2,\\
\end{eqnarray*}
Hence $(4147,10672)=29.$


We now use the steps in the Euclidean algorithm to write the
greatest common divisor of two integers as a linear combination of
the two integers.  The following example will actually determine the
variables $m$ and $n$ described in Theorem \ref{thm9}.  The
following algorithm can be described by a general form but for the
sake of simplicity of expressions we will present an example that
shows the steps for obtaining the greatest common divisor of two
integers as a linear combination of the two integers.

\begin{example}
Express 29 as a linear combination of $4147$ and $10672$:\\
\end{example}
\begin{eqnarray*}
29&=&551-9\cdot 58,\\
  &=& 551-9(609-551\cdot 1),\\
  &=& 10.551-9.609,\\
  &=& 10\cdot (1769-609\cdot 2)-9\cdot 609,\\
  &=& 10\cdot 1769-29\cdot 609,\\
  &=& 10\cdot 1769-29(2378-1769\cdot 1),\\
  &=& 39\cdot 1769-29\cdot 2378,\\
  &=& 39(4147-2378\cdot 1)-29\cdot 2378,\\
  &=& 39\cdot 4147-68\cdot 2378,\\
  &=& 39\cdot 4147-68(10672-4147\cdot 2),\\
  &=& 175\cdot 4147-68\cdot 10672,
\end{eqnarray*}
As a result, we see that $29=175\cdot 4147-68\cdot 10672$.

\textbf{Exercises}
\begin{enumerate}
\item{Use the Euclidean algorithm to find the greatest common
divisor of 412 and 32 and express it in terms of the two
integers.}\item{Use the Euclidean algorithm to find the greatest
common divisor of 780 and 150 and express it in terms of the two
integers.}\item{Find the greatest common divisor of $70,98,
108$.}\item{Let $a$ and $b$ be two positive even integers.  Prove
that $(a,b)=2(a/2,b/2).$}\item{Show that if $a$ and $b$ are positive
integers where $a$ is even and $b$ is odd, then $(a,b)=(a/2,b).$}
\end{enumerate}


\chapter{Diophantine Equations}
\section{Linear Diophantine Equations}
\index{Diophantine Equations} In this section, we discuss equations
in two variables called diophantine equations.  These kinds of
equations require integer solutions.  The goal of this section is to
present the set of points that determine the solution to this kind
of equations. Geometrically speaking, the diophantine equation
represent the equation of a straight line.  We need to find the
points whose coordinates are integers and through which the straight
line passes. \index{Linear Equation}
\begin{definition}
A linear equation of the form $ax+by=c$ where $a,b$ and $c$ are
integers is known as a linear diophantine equation.
\end{definition}

Note that a solution to the linear diophantine equation $(x_0,y_0)$
requires $x_0$ and $y_0$ to be integers.  The following theorem
describes the case in which the diophantine equation has a solution
and what are the solutions of such equations.

\begin{theorem}
The equation $ax+by=c$ has integer solutions if and only if $d\mid
c$ where $d=(a,b)$.  If the equation has one solution $x=x_0$,
$y=y_0$, then there are infinitely many solutions and the solutions
are given by
\begin{equation*}
x=x_0+(b/d)t \ \ \ \ \ y=y_0-(a/d)t
\end{equation*}
where $t$ is an arbitrary integer.
\end{theorem}

\begin{proof}
Suppose that the equation $ax+by=c$ has integer solution $x$ and
$y$.  Thus since $d\mid a$ and $d\mid b$, then
\begin{equation*}
d\mid (ax+by)=c.
\end{equation*}
Now we have to prove that if $d\mid c$, then the equation has
integral solution.  Assume that $d\mid c$. By theorem 9, there exist
integers $m$ and $n$ such that
\begin{equation*}
d=am+bn.
\end{equation*}
And also there exists integer $k$ such that
\begin{equation*}
c=dk
\end{equation*}
Now since $c=ax+by$, we have
\begin{equation*}
c=dk=(ma+nb)k=a(km)+b(nk).
\end{equation*}
Hence a solution for the equation $ax+by=c$ is
\begin{equation*}
x_0=km \ \ \mbox{and} \ \  y_0=kn.
\end{equation*}
What is left to prove is that we have infinitely many solutions.
Let
\begin{equation*}
x=x_0+(b/d)t \ \ \mbox{and} \ \  y=y_0-(a/d)t.
\end{equation*}
We have to prove now that $x$ and $y$ are solutions for all integers
$t$. Notice that
\begin{equation*}
ax+by=a(x_0+(b/d)t)+b(y_0-(a/d)t)=ax_0+by_0=c.
\end{equation*}
We now show that every solution for the equation $ax+by=c$
is of the form
\begin{equation*}
x=x_0+(b/d)t \mbox{and} \ \  y=y_0-(a/d)t.
\end{equation*}
Notice that since $ax_0+by_0=c$, we have
\begin{equation*}
a(x-x_0)+b(y-y_0)=0.
\end{equation*}
Hence
\begin{equation*}
a(x-x_0)=b(y-y_0).
\end{equation*}
Dividing both sides by $d$, we get
\begin{equation*}
a/d(x-x_0)=b/d(y-y_0).
\end{equation*}
Notice that $(a/d,b/d)=1$ and thus we get by Lemma 4 that $a/d\mid
y-y_0$. As a result, there exists an integer $t$ such that
$y=y_0-(a/d)t$. Now substituting $y-y_0$ in the equation
\begin{equation*}
a(x-x_0)=b(y-y_0).
\end{equation*}
We get
\begin{equation*}
x=x_0+(b/d)t.
\end{equation*}
\end{proof}

\begin{example}
The equation $3x+6y=7$ has no integer solution because $(3,6)=3$
does not divide $7$.
\end{example}

\begin{example}
There are infinitely many integer solutions for the equation
$4x+6y=8$ because $(4,6)=2 \mid 8$.  We use the Euclidean algorithm
to determine $m$ and $n$ where $4m+6n=2$.  It turns out that
$4(-1)+6(1)=2$. And also $8=2.4$. Thus $x_0=4.(-1)=-4$ and
$y_0=4.1=4$ is a particular solution. The solutions are given by
\begin{equation*}
x=-4+3t \ \ \ \ \  y=4-2t
\end{equation*}
for all integers $t$.
\end{example}

\textbf{Exercises}
\begin{enumerate}
\item{Either find all solutions or prove that there are no
solutions for the diophantine equation $21x+7y=147.$}\item{Either
find all solutions or prove that there are no solutions for the
diophantine equation $2x+13y=31.$}\item{Either find all solutions or
prove that there are no solutions for the diophantine equation
$2x+14y=17.$}\item{A grocer orders apples and bananas at a total
cost of \$8.4.  If the apples cost 25 cents each and the bananas 5
cents each, how many of each type of fruit did he order.}
\end{enumerate}

\chapter{Congruences}

A congruence is nothing more than a statement about divisibility.
The theory of congruences was introduced by Carl Friedreich Gauss.
Gauss contributed to the basic ideas of congruences and proved
several theorems related to this theory. We start by introducing
congruences and their properties.  We proceed to prove theorems
about the residue system in connection with the Euler
$\phi$-function.  We then present solutions to linear congruences
which will serve as an introduction to the Chinese remainder
theorem.    We present finally important congruence theorems derived
by Wilson, Fermat and Euler.

\section{Introduction to congruences}
As we mentioned in the introduction, the theory of congruences was
developed by Gauss at the beginning of the nineteenth century.
\index{Congruence}
\begin{definition}
Let m be a positive integer. We say that $a$ is congruent to $b$
modulo m if $m \mid (a-b)$ where $a$ and $b$ are integers, i.e. if $a=b+km$ where $k\in \mathbb{Z}$.
\end{definition}
\index{Modulo} If $a$ is congruent to $b$ modulo $m$, we write
$a\equiv b(mod\ m)$.

\begin{example}
$19\equiv 5 (mod \ 7)$.  Similarly $2k+1 \equiv 1 (mod\ 2)$ which
means every odd number is congruent to 1 modulo 2.
\end{example}

There are many common properties between equations and congruences.
Some properties are listed in the following theorem.

\begin{theorem}
Let $a, b, c$ and $d$ denote integers.  Let $m$ be a
positive integers.  Then:

\begin{enumerate}
\item{If $a \equiv b(mod \ m)$, then $b\equiv a (mod \ m)$.}
\item{If $a\equiv b(mod \ m)$ and $b\equiv c(mod \ m)$, then
$a\equiv c (mod \ m)$.}
\item{If $a\equiv b(mod\ m)$, then $a+c
\equiv b+c (mod \ m)$.}
\item{If $a\equiv b(mod\ m)$, then $a-c
\equiv b-c (mod \ m)$.}
\item{If $a\equiv b(mod\ m)$, then $ac
\equiv bc (mod \ m)$.}
\item{If $a\equiv b(mod\ m)$, then $ac \equiv
bc (mod \ mc)$, for $c>0$.}
\item{If $a\equiv b(mod\ m)$ and $c
\equiv d (mod \ m)$ then $a+c \equiv (b+d) (mod \ m)$.}
\item{If
$a\equiv b(mod\ m)$ and $c \equiv d (mod \ m)$ then $a-c \equiv (b-d)
(mod \ m)$.}
\item{If $a\equiv b(mod\ m)$ and $c \equiv d (mod \ m)$
then $ac \equiv bd (mod \ m)$.}
\end{enumerate}
\end{theorem}

\begin{proof}
\begin{enumerate}
\item{If $a \equiv b(mod \ m)$, then $m\mid (a-b)$. Thus there
exists integer $k$ such that $a-b=mk$, this implies $b-a=m(-k)$ and
thus $m\mid (b-a)$.  Consequently $b\equiv a (mod \ m)$.}

\item{Since $a\equiv b(mod \ m)$, then $m\mid (a-b)$. Also,
$b\equiv c(mod \ m)$, then $m\mid (b-c)$.  As a result, there exit
two integers $k$ and $l$ such that $a=b+mk$ and $b=c+ml$, which imply that $a=c+m(k+l)$ giving that $a=c (mod \ m)$.}

\item{Since $a\equiv b (mod \ m)$, then $m \mid (a-b)$. So if we
add and subtract $c$ we get
\begin{equation*}
m\mid ((a+c)-(b+c))
\end{equation*}
and as a result
\begin{equation*}
a+c\equiv b+c (mod \ m). \end{equation*}}
\item{Since $a\equiv b (mod \ m)$, then $m \mid (a-b)$ so we can
subtract and add $c$ and we get
\begin{equation*}
m\mid ((a-c)-(b-c))
\end{equation*}
and as a result
\begin{equation*}
a-c\equiv b-c (mod \ m). \end{equation*}}
\item{If $a \equiv b(mod \ m)$, then $m\mid (a-b)$. Thus there
exists integer $k$ such that $a-b=mk$ and as a result $ac-bc=m(kc)$.
Thus
\begin{equation*}
m\mid (ac-bc)
\end{equation*}
and hence
\begin{equation*}
ac\equiv bc (mod \ m). \end{equation*}}
\item{If $a \equiv b(mod \
m)$, then $m\mid (a-b)$. Thus there exists integer $k$ such that
$a-b=mk$ and as a result
\begin{equation*}
ac-bc=mc(k).
\end{equation*}
Thus
\begin{equation*}
mc\mid (ac-bc)
\end{equation*}
and hence
\begin{equation*}
ac\equiv bc (mod \ mc). \end{equation*}}
\item{Since $a\equiv b(mod \ m)$, then $m\mid (a-b)$. Also, $c\equiv
d(mod \ m)$, then $m\mid (c-d)$. As a result, there exits two
integers $k$ and $l$ such that $a-b=mk$ and $c-d=ml$. Note that
\begin{equation*}
(a-b)+(c-d)=(a+c)-(b+d)=m(k+l).
\end{equation*}
As a result,
\begin{equation*}
m\mid ((a+c)-(b+d)),
\end{equation*}
hence
\begin{equation*}
a+c\equiv b+d(mod \ m).\end{equation*}}

\item{If $a=b+mk$ and $c=d+ml$ where $k$ and $l$ are integers, then
\begin{equation*}
(a-b)-(c-d)=(a-c)-(b-d)=m(k-l).
\end{equation*}
As a result,
\begin{equation*}
m\mid ((a-c)-(b-d)),
\end{equation*}
hence
\begin{equation*}
a-c\equiv b-d(mod \ m). \end{equation*}}

\item{There exit two integers $k$ and $l$
such that $a-b=mk$ and $c-d=ml$ and thus $ca-cb=m(ck)$ and
$bc-bd=m(bl)$. Note that
\begin{equation*}
(ca-cb)+(bc-bd)=ac-bd=m(kc-lb).
\end{equation*}
As a result, \begin{equation*}m\mid (ac-bd), \end{equation*}hence
\begin{equation*}
ac\equiv bd(mod \ m). \end{equation*}}
\end{enumerate}
\end{proof}


\begin{examples}
\begin{enumerate}
\item{Because $ 14\equiv 8(mod\  6)$ then $8 \equiv 14 (mod\ 6)$.}
\item{Because $22\equiv 10(mod \ 6)$ and $10 \equiv 4(mod \ 6)$.
Notice that $22\equiv 4(mod \ 6)$.}\item{Because $50\equiv 20 (mod\
15)$, then $50+5=55\equiv 20+5=25(mod\ 15)$.}\item{Because $50\equiv
20 (mod\ 15)$, then $50-5=45\equiv 20-5=15(mod\ 15)$.}\item{Because
$19\equiv 16(mod3)$, then $2(19)=38\equiv 2(16)=32(mod \
3).$}\item{Because $19\equiv 16(mod3)$, then $2(19)=38\equiv
2(16)=32(mod \ 2(3)=6).$}\item{Because $19\equiv 3 (mod \ 8)$ and
$17\equiv 9(mod \ 8)$, then $19+17=36\equiv 3+9=12(mod \
8)$}.\item{Because $19\equiv 3 (mod \ 8)$ and $17\equiv 9(mod \ 8)$,
then $19-17=2\equiv 3-9=-6(mod \ 8)$}.\item{Because $19\equiv 3 (mod
\ 8)$ and $17\equiv 9(mod \ 8)$, then $19(17)=323\equiv 3(9)=27(mod
\ 8)$}.
\end{enumerate}

\end{examples}

We now present a theorem that will show one difference between
equations and congruences.  In equations, if we divide both sides of
the equation by a non-zero number, equality holds.  While in
congruences, it is not necessarily true.  In other words, dividing
both sides of the congruence by the same integer doesn't preserve
the congruence.

\begin{theorem}
\begin{enumerate}
\item {If $a,b, c$ and $m$ are integers such that $m>0$, $d=(m,c)$ and
$ac\equiv bc(mod \ m)$, then $a\equiv b (mod \ m/d)$.}
\item {If $(m,c)=1$ then $a=b(mod \ m)$ if $ac\equiv bc(mod \ m)$.}
\end{enumerate}
\end{theorem}

\begin{proof}
Part 2 follows immediately from Part 1. For Part 1, if $ac\equiv
bc(mod \ m)$, then
\begin{equation*}
m\mid (ac-bc)=c(a-b).
\end{equation*}
Hence there exists $k$ such that $c(a-b)=mk$. Dividing both sides by
$d$, we get $(c/d)(a-b)=k(m/d)$. Since $(m/d,c/d)=1$,  it follows
that $m/d \mid (a-b)$.  Hence $a\equiv b (mod \ m/d)$.
\end{proof}

\begin{example}
$38 \equiv 10 (mod\ 7)$.  Since $(2,7)=1$ then $19\equiv 5 (mod \
7).$
\end{example}

The following theorem combines several congruences of two numbers
with different moduli.

\begin{theorem}
If
\begin{equation*}
a\equiv b(mod \ m_1), a\equiv b(mod \ m_2),...,a\equiv b(mod \ m_t)
\end{equation*}
where $a,b,m_1,m_2,...,m_t$ are integers and $m_1,m_2,...,m_t$ are
positive, then
\begin{equation*}
a\equiv b(mod \ \langle m_1,m_2,...m_t\rangle)
\end{equation*}
\end{theorem}

\begin{proof}
Since $a\equiv b (mod \ m_i)$ for all $1\leq i\leq t$.  Thus $m_i
\mid (a-b)$.  As a result,
\begin{equation*}
\langle m_1,m_2,...,m_t\rangle \mid (a-b)
\end{equation*}
(prove this as an exercise).  Thus
\begin{equation*}
a\equiv b(mod \ \langle m_1,m_2,...m_t\rangle). \end{equation*}
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Determine whether 3 and 99 are congruent modulo 7 or not.}
\item{Show that if $x$ is an odd integer, then $x^2\equiv 1(mod \
8)$} \item{Show that if $a,b, m$ and $n$ are integers such that $m$
and $n$ are positive, $n \mid m$ and $a\equiv b (mod \ m)$, then
$a\equiv b (mod \ n).$}\item{Show that if $a_i\equiv b_i(mod \ m)$
for $i=1,2,...,n$, where $m$ is a positive integer and $a_i,b_i$ are
integers for $j=1,2,...,n$, then $\sum_{i=1}^na_i\equiv
\sum_{i=1}^nb_i(mod \ m)$}\item{For which $n$ does the expression
$1+2+...+(n-1)\equiv 0(mod \ n)$ holds.}

\end{enumerate}

\chapter{Divisibility Test}

\chapter{Linear congruences and solutions}
\section{Linear Congruences}
Because congruences are analogous to equations, it is natural to ask
about solutions of linear equations.  In this section, we will be
discussing linear congruences of one variable and their solutions.
We start by defining linear congruences. \index{Linear Congruence}
\begin{definition}
A congruence of the form $ax\equiv b(mod\ m)$ where $x$ is an
unknown integer is called a linear congruence in one variable.
\end{definition}

It is important to know that if $x_0$ is a solution for a linear
congruence, then all integers $x_i$ such that $x_i\equiv x_0 (mod \
m)$ are solutions of the linear congruence. Notice also that
$ax\equiv b (mod\ m)$ is equivalent to a linear Diophantine equation
i.e. there exists $y$ such that $ax-my=b$.  We now prove theorems
about the solutions of linear congruences.

\begin{theorem}
Let $a,b$ and $m$ be integers such that $m>0$ and let $c=(a,m)$. If
$c$ does not divide $b$, then the congruence $ax\equiv b(mod \ m)$
has no solutions. If $c\mid b$, then
\begin{equation*}
ax\equiv b(mod \ m)
\end{equation*}
has exactly $c$ incongruent solutions modulo $m$.
\end{theorem}

\begin{proof}
As we mentioned earlier, $ax\equiv b(mod \ m)$ is equivalent to
$ax-my=b$.  By Theorem 19 on Diophantine equations, we know that if
$c$ does not divide $b$, then the equation, $ax-my=b$ has no
solutions. Notice also that if $c\mid b$, then there are infinitely
many solutions whose variable $x$ is given by
\begin{equation*}
x=x_0+(m/c)t
\end{equation*}
Thus the above values of $x$ are solutions of the congruence
$ax\equiv b(mod \ m)$.  Now we have to determine the number of
incongruent solutions that we have.  Suppose that two solutions are
congruent, i.e.
\begin{equation*}
x_0+(m/c)t_1\equiv x_0+(m/c)t_2(mod \ m).
\end{equation*}
Thus we get
\begin{equation*}
(m/c)t_1\equiv (m/c)t_2(mod \ m).
\end{equation*}
Now notice that $(m,m/c)=m/c$ and thus
\begin{equation*}
t_1\equiv t_2(mod \ c).
\end{equation*}
Thus we get a set of incongruent solutions given by $x=x_0+(m/c)t$,
where $t$ is taken modulo $c$.
\end{proof}

\begin{remark}
Notice that if $c=(a,m)=1$, then there is a unique solution modulo m
for the equation $ax\equiv b(mod \ m)$.
\end{remark}

\begin{example} Let us find all the solutions of the congruence $3x\equiv 12 (mod \
6)$.  Notice that $(3,6)=3$ and $3\mid 12$.  Thus there are three
incongruent solutions modulo $6$.  We use the Euclidean algorithm to
find the solution of the equation $3x-6y=12$ as described in chapter
2. As a result, we get $x_0=6$.  Thus the three incongruent
solutions are given by $x_1=6(mod \ 6)$, $x_1=6+2=2(mod \ 6)$ and
$x_2=6+4=4(mod \ 6)$.
\end{example}

As we mentioned earlier in Remark 2, the congruence $ax\equiv b(mod
\ m)$ has a unique solution if $(a,m)=1$.  This will allow us to
talk about modular inverses.

\begin{definition}
A solution for the congruence $ax\equiv 1 (mod\ m)$ for $(a,m)=1$ is
called the modular inverse of $a$ modulo m. We denote such a solution by $\bar{a}$.
\end{definition} \index{Modular Inverse} \index{Inverse}

\begin{example}
The modular inverse of 7 modulo 48 is 7.  Notice that a solution for
$7x\equiv 1(mod \ 48)$ is $x\equiv 7 (mod \ 48)$.
\end{example}

\textbf{Exercises}
\begin{enumerate}
\item{Find all solutions of $3x\equiv 6(mod \ 9)$.}\item{Find all
solutions of $3x\equiv 2(mod \ 7)$.}\item{Find an inverse modulo 13
of 2 and of 11.}\item{Show that if $\bar{a}$ is the inverse of $a$
modulo $m$ and $\bar{b}$ is the inverse of $b$ modulo $m$, then
$\bar{a}\bar{b}$ is the inverse of $ab$ modulo $m$.}
\end{enumerate}

\chapter{Algorithm for Linear congruences}

\chapter{Chinese Remainder Theorem}
\section{The Chinese Remainder Theorem}
In this section, we discuss the solution of a system of congruences
having different moduli.  An example of this kind of systems is the
following; find a number that leaves a remainder of 1 when divided
by 2, a remainder of 2 when divided by three and a remainder of 3
when divided by 5.  This kind of question can be translated into the
language of congruences.  As a result, in this chapter, we present a
systematic way of solving this system of congruences. \index{Chinese
Remainder Theorem}
\begin{theorem}
The system of congruences
\begin{eqnarray*}
&& x\equiv b_1(mod \ n_1),\\&&x\equiv b_2(mod \
n_2),\\&&.\\&&.\\&&.\\&& x\equiv b_t(mod \ n_t),
\end{eqnarray*}
has a unique solution modulo $N=n_1n_2...n_t$ if $n_1,n_2,...,n_t$
are pairwise relatively prime positive integers.
\end{theorem}

\begin{proof}
Let $N_k=N/n_k$.  Since $(n_i,n_j)=1$ for all $i\neq j$, then
$(N_k,n_k)=1$.  Hence by Theorem 26 , we can find an inverse $y_k$
of $N_k$ modulo $n_k$ such that $N_ky_k\equiv 1(mod \ n_k)$.
Consider now
\begin{equation*}
x=\sum_{i=1}^tb_iN_iy_i
\end{equation*}
Since
\begin{equation*}
N_j\equiv 0(mod \ n_k) \ \ \mbox{for all} \ \  j\neq k,
\end{equation*}
thus we see that
\begin{equation*}
x\equiv b_kN_ky_k(mod \ n_k).
\end{equation*}
Also notice that $N_ky_k\equiv 1(mod \ n_k)$.  Hence $x$ is a
solution to the system of t congruences.   We have to show now that
any two solutions are congruent modulo $N$.  Suppose now that you
have two solutions $x_0,x_1$ to the system of congruences.  Then
\begin{equation*}
x_0\equiv x_1(mod \ n_k)
\end{equation*}
for all $1\leq k\leq t$.  Thus by Theorem 23, we see that
\begin{equation*}
x_0\equiv x_1(mod \ N).
\end{equation*}
Thus the solution of the system is unique modulo $N$.
\end{proof}

We now present an example that will show how the Chinese remainder
theorem is used to determine the solution of a given system of
congruences.

\begin{example}
Solve the system
\begin{eqnarray*}
&& x\equiv 1(mod \ 2)\\&& x\equiv 2(mod \ 3)\\&& x\equiv 3(mod \ 5).
\end{eqnarray*}
We have $N=2.3.5=30$.  Also
\begin{equation*}
N_1=30/2=15, N_2=30/3=10 \mbox{and} \ \  N_3=30/5=6.
\end{equation*}
So we have to solve now $15y_1\equiv 1(mod \ 2)$. Thus
\begin{equation*}
y_1\equiv 1(mod \ 2).
\end{equation*}
In the same way, we find that
\begin{equation*}
y_2\equiv 1(mod \ 3) \mbox{and} \ \   y_3\equiv 1(mod \ 5).
\end{equation*}
As a result, we get
\begin{equation*}
x\equiv 1.15.1+2.10.1+3.6.1\equiv 53\equiv 23 (mod \ 30).
\end{equation*}
\end{example}

\textbf{Exercises}
\begin{enumerate}
\item{Find an integer that leaves a remainder of 2 when divided by
either 3 or 5, but that is divisible by 4.}\item{Find all integers
that leave a remainder of 4 when divided by 11 and leaves a
remainder of 3 when divided by 17.}\item{Find all integers that
leave a remainder of 1 when divided by 2, a remainder of 2 when
divided by 3 and a remainder of 3 when divided by 5. }
\end{enumerate}

\chapter{Dirichlet, Wilson's Theorems}

\begin{lemma} Let $p$ be an odd prime and suppose $ p \nmid a.$ If there exists a number $b$ such that $b^2=a (mod \ p)$  then the congruence $x^2 \equiv a (mod \ p)$ has precisely two incongruent solutions modulo $p$.
\end{lemma}

\begin{proof}
There are at least two incongruent solutions of the congruence since $(-b)^2 \equiv a  (mod \ p)$ and $b \not\equiv (-b) ( mod \ p)$ as $p\neq 2$. To show there are only these two solutions we consider $x^2-b^2 \equiv 0 (mod \ p) $, it means that $ p \mid (x-b)(x+b)$. As $p$ is a prime number so it must divide at least one of them, hence the result.
\end{proof}

\begin{theorem}
\textbf{Dirichlet  Theorem} Let $p$ be a prime  and $1 \leq a \leq p-1 $. If the congruence $ x^2 \equiv a (mod \ p) $ does not have solution then $ p-1 ! \equiv a^{(p-1)/2} (mod \ p) $ and if the congruence have the solution then $p-1 ! \equiv -a^{(p-1)/2} (mod \ p) $
\end{theorem}

\begin{proof}
The result is obvious for the $p=2$ , so assume that $p$ is an odd prime. If $ 1 \leq m \leq p-1$ then there exists a unique $n$ such that $ 1 \leq n \leq p-1 $ and $mn \equiv a (mod \ p).$ Call $m$ and $n$ are corresponding numbers. If $x^2 \equiv a (mod \ p)$ does not have a solution then $m \neq n$ for the corresponding numbers $m$ and $n$. Therefore the numbers from $1$ to $p-1$ can be paired off into $(p-1)/2$ corresponding pairs. The product of all the corresponding pairs is congruent to $a^ {(p-1)/2} (mod / p)$ but it is clearly also equal to $(p-1) !$. Therefore, $(p-1)! \equiv a^{(p-1)/2} (mod \ p)$.\\
If $ x^2 \equiv a (mod \ p) $ is solvable, it has a solution $b$ such that $ 1 \leq b \leq p-1$. The only other solution in the range is $p-b$. Arrange the remaining $p-3$ numbers from $1$ to $p-1$ into corresponding pairs, their product is then congruent to $a^ {(p-3)/2} (mod \ p)$. The product of the two remaining numbers $b$ and $p-b$ is congruent to $-a (mod \ p)$. Hence $(p-1) ! \equiv (-a)a^{(p-3)/2}=-a^{(p-1)/2} (mod \ p)$.
\end{proof}

One of the significance of this result is Wilson Theorem.

\begin{theorem}
\textbf{Wilson's Theorem} If $p$ is prime then $(p-1)! \equiv -1 ( mod \ p)$
\end{theorem}

\begin{proof}
Apply the Dirichlet theorem for $a=1$. It is obvious that the congruence $x^2 \equiv 1 (mod \ p)$ has a solution namely $x=1$. Which implies that $(p-1)!\equiv -1^{(p-1)/2} = (-1) (mod \ p)$.
\end{proof}
\subsection{Euler Criterion}
\begin{theorem}
\textbf{Euler's Criterion} Let $p$ be an odd prime and suppose $ p \nmid a$. Then $ x^2 \equiv a (mod \ p)$ is solvable or not solvable according as $a^{(p-1)/2} \equiv 1 (mod \ p)$ or $ a^{(p-1)/2} \equiv -1 (mod \ p)$.
\end{theorem}

\begin{proof}
Suppose the congruence has a solution, then by the Dirichlet theorem and Wilson's theorem $-1 \equiv - a^{(p-1)/2} (mod \ p)$ and multiplication by $-1$  gives the result. The argument when the congruence has no solution is essentially the same.
\end{proof}



\begin{lemma}
Let $a,u,v$ be integers with $u$ and $v$ an positive and $d=(u,v)$ and let $m > 0$. If $a^u \equiv 1 (mod \ m)$ and
$ a^v \equiv 1 (mod \  m)$ then $a^d \equiv 1 (mod \ m).$
\end{lemma}

\begin{proof}
We know that $d$ can be written as the linear combination of the integers $u$ and $v$ i.e. $d=su + tv$. As $d$ is positive, one of the $s$ or $t$ must be positive. With out loss of generality assume that it is $t$. Then $(a^u)^s = a^d (a^v)^t $. Since $a^u \equiv a^v \equiv 1 (mod \ m)$, it follows that $a^d \equiv 1 (mod m).$
\end{proof}


\chapter{Fermat Little Theorem, Euler $\phi$ function}

\begin{theorem}
\textbf{Fermat's Theorem} Let $p$ be a prime and suppose $ p \nmid a$. then $ a^{p-1} \equiv 1 (mod \ p).$ Equivalently, if $a$ is any integer, then $a^p \equiv a (mod \ p)$.
\end{theorem}

\begin{proof}
We know by Euler's criterion $a^{(p-1)/2} \equiv \pm 1 (mod \ p)$. Square both sides of the congruence and we will get the theorem.
\end{proof}


Note also that the converse of Wilson's theorem also holds.  The
converse tells us whether an integer is prime or not.

\begin{theorem}
If $m$ is a positive integer with $m\geq 2$ such that
\begin{equation*}
(m-1)!+1\equiv 0 \ (mod \ m)
\end{equation*}
then $m$ is prime.
\end{theorem}
\begin{proof}
Suppose that $m$ has a proper divisor $c_1$ and that
\begin{equation*}
(m-1)!+1\equiv 0(mod \ m).
\end{equation*}
That is $m=c_1c_2$ where $1<c_1<m$ and $1<c_2<m$.  Thus $c_1$ is a
divisor of $(m-1)!$. Also, since
\begin{equation*}
m\mid ((m-1)!+1),
\end{equation*}
we get
\begin{equation*}
c_1\mid ((m-1)!+1).
\end{equation*}
As a result, by Theorem 4, we get that
\begin{equation*}
c_1\mid ((m-1)!+1-(m-1)!),
\end{equation*}
which gives that $c_1\mid 1$.  This is a contradiction and hence $m$
is prime.
\end{proof}


 We now present a function that counts the number of positive
integers less than a given integer that are relatively prime to that
given integer. This function is called Euler $\phi$-function. We
will discuss the properties of Euler $\phi$-function in details in
chapter 5. It will be sufficient for our purposes in this chapter to
the notation. \index{Euler $\phi$ Function}
\begin{definition}
The Euler $\phi$-function of a positive integer n, denoted by
$\phi(n)$ counts the number of positive integers less than $n$ that
are relatively prime to n.
\end{definition}

\begin{example}
Since 1 and 3 are the only two integers that are relatively prime to
4 and less than 4, then $\phi(4)=2$.  Also, 1,2,...,6 are the
integers that are relatively prime to 7 that are less than 7, thus
$\phi(7)=6$.
\end{example}

Now we can say that the number of elements in a reduced residue
system modulo $n$ is $\phi(n)$.

\begin{theorem}
If $a_1,a_2,...,a_{\phi(n)}$ is a reduced residue system modulo $n$
and $(k,n)=1$, then $ka_1,ka_2,...,ka_{\phi(n)}$ is a reduced
residue system modulo $n$.
\end{theorem}

\begin{proof}
The proof proceeds exactly in the same way as that of Theorem 24.
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Give a reduced residue system  modulo 12.} \item{Give a
complete residue system modulo 13 consisting only of odd
integers.}\item{Find $\phi(8)$ and $\phi(101)$.}
\end{enumerate}


\chapter{Euler Theorem}






Suppose $m$ is a positive integer.  Given two integers $a$ and $b$,
we see that by the division algorithm that $a=bm+r$ where $0\leq
r<m$.  We call $r$ the least nonnegative residue of $a$ modulo $m$.
As a result, we see that any integer is congruent to one of the
integers $0,1,2,...,m-1$ modulo m. \index{Complete Residue System}
\begin{definition}
A complete residue system modulo $m$ is a set of integers such that
every integer is congruent modulo $m$ to exactly one integer of the
set.
\end{definition}
The easiest complete residue system modulo $m$ is the set of
integers $0,1,2,...,m-1$.  Every integer is congruent to one of
these integers modulo m.

\begin{example}
The set of integers $\{0,1,2,3,4\}$ form a complete residue system
modulo $5$.  Another complete residue system modulo $5$ could be
$6,7,8,9,10$.
\end{example}
\index{Reduced Residue System}
\begin{definition}
A reduced residue system modulo $m$ is a set of integers $r_i$ such
that $(r_i,m)=1$ for all $i$ and $r_i \neq r_j (mod \ m)$ if $i\neq
j$.
\end{definition}

Notice that, a reduced residue system modulo $m$ can be obtained by
deleting all the elements of the complete residue system set that
are not relatively prime to $m$.

\begin{example}
The set of integers $\{1,5\}$ is a reduced residue system modulo
$6$.
\end{example}

The following lemma will help determine a complete residue system
modulo any positive integer $m$. \index{Incongruent Integers}
\begin{lemma}
A set of $m$ incongruent integers modulo $m$ forms a complete
residue system modulo $m$.
\end{lemma}

\begin{proof}
We will prove this lemma by contradiction.  Suppose that the set of
$m$ integers does not form a complete residue system modulo $m$.
Then we can find at least one integer $a$ that is not congruent to
any element in this set. Hence non of the elements of this set is
actually congruent to the remainder when $a$ is divided by $m$. Thus
dividing by $m$ yields to at most $m-1$ remainders. Therefore by the
pigeonhole principle, at least two integers in the set that have the
same remainder modulo $m$. This is a contradiction since the set of
integers is formed of $m$ integers that are incongruent modulo $m$.
\end{proof}


\begin{theorem}
If $a_1, a_2,...,a_m$ is a complete residue system modulo $m$, and
if $k$ is a positive integer with $(k,m)=1$, then
\begin{equation*}
ka_1+b, ka_2+b,...,ka_m+b
\end{equation*}
is another complete residue system modulo $m$ for any integer $b$.
\end{theorem}

\begin{proof}
Let us prove first that no two elements of the set $\{ka_1+b,
ka_2+b,...,ka_m+b\}$ are congruent modulo $m$.  Suppose there exists
$i$ and $j$ such that
\begin{equation*}
ka_i+b\equiv ka_j+b(mod\ m).
\end{equation*}
Thus we get that
\begin{equation*}
ka_i\equiv ka_j(mod \ m).
\end{equation*}
Now since $(k,m)=1$, we get
\begin{equation*}
a_i\equiv a_j(mod\ m)
\end{equation*}
But for $i\neq j$, $a_i$ is inequivalent to $a_j$ modulo $m$. Thus
$i=j$. Now notice that there are $m$ inequivalent integers modulo m
and thus by Lemma 10, the set form a complete residue system modulo
$m$.
\end{proof}


\begin{theorem}\textbf{Euler's Theorem}
If $m$ is a positive integer and $a$ is an integer such that
$(a,m)=1$, then
\begin{equation*}
a^{\phi(m)}\equiv 1(mod \ m)
\end{equation*}
\end{theorem}

\begin{example}
Note that $3^4=81 \equiv 1(mod \ 5)$. Also,
$2^{\phi(9)}=2^6=64\equiv 1(mod \ 9)$.
\end{example}

We now present the proof of Euler's theorem.

\begin{proof}
Let $k_1,k_2,...,k_{\phi(m)}$ be a reduced residue system modulo
$m$. By Theorem 25, the set
\begin{equation*}
\{ak_1,ak_2,...,ak_{\phi(m)}\}
\end{equation*}
also forms a reduced residue system modulo $m$. Thus
\begin{equation*}
ak_1ak_2...ak_{\phi(m)}=a^{\phi(m)}k_1k_2...k_{\phi(m)}\equiv
k_1k_2...k_{\phi(m)}(mod \ m).
\end{equation*}
Now since $(k_i,m)=1$ for all $1\leq i\leq \phi(m)$, we have
$(k_1k_2...k_{\phi(m)},m)=1$.  Hence by Theorem 22 we can cancel the
product of $k$'s on both sides and we get
\begin{equation*}
a^{\phi(m)}\equiv 1(mod \ m).
\end{equation*}
\end{proof}

\begin{theorem}
If $p$ is a prime number and $a$ is a positive integer, then
$a^p\equiv a(mod \ p)$.
\end{theorem}

\begin{proof}
If $p\nmid a$, by Fermat's theorem we know that
\begin{equation*}
a^{p-1}\equiv 1(mod \ p).
\end{equation*}
Thus, we get
\begin{equation*}
a^{p}\equiv a(mod \ p).
\end{equation*}
Now if $p\mid a$, we have
\begin{equation*}
a^p\equiv a\equiv 0 (mod \ p).
\end{equation*}
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Show that 10!+1 is divisible by 11.}\item{What is the
remainder when 5!25! is divided by 31?}\item{What is the remainder
when $5^{100}$ is divided by 7?}\item{Show that if $p$ is an odd
prime, then $2(p-3)!\equiv -1(mod \ p)$.} \item{Find a reduced
residue system modulo $2^m$, where $m$ is a positive
integer.}\item{Show that if $a_1,a_2,...,a_{\phi(m)}$ is a reduced
residue system modulo $m$, where $m$ is a positive integer with
$m\neq 2$, then $a_1+a_2+...+a_{\phi(m)}\equiv 0 (mod \
m)$.}\item{Show that if $a$ is an integer such that $a$ is not
divisible by 3 or such that $a$ is divisible by 9, then $a^7\equiv a
(mod \ 63)$.}
\end{enumerate}






\chapter{Exercises for FLT, Euler and $\phi$ function }


\chapter{Order of an integer}



Now we study the order of an integer modulo $n$, where
$n$ is positive.  We also define primitive roots and related
results.
\begin{def1}
Let $(a,b)=1$.  The smallest positive integer $x$ such that $a^{x}
\equiv 1(mod \ b)$ is called the order of $a$ modulo $b$.  We denote
the order of $a$ modulo $b$ by $ord_ba$.
\end{def1}

\begin{example}
$ord_72=3$ since $2^3\equiv 1(mod \ 7)$ while $2^1\equiv 2(mod \ 7)$
and $2^2\equiv 4(mod \ 7)$.
\end{example}

\begin{theorem}
Let $m$ be a positive integer and suppose that $(a,m)=1$
\begin{enumerate}
  \item $a^s \equiv 1 (mod \ m)$ if and only if $ord a \mid s$. In particular $ ord a \mid \phi(m)$.
  \item $a^s \equiv a^t (mod \ m)$ if and only if $ \equiv t (mod \ ord a)$
\end{enumerate}
\end{theorem}

\begin{proof}
\textbf{1} If $ s = k ord a$ then $a^s = (a ^{ord a})^k \equiv 1^k = 1 (mod \ m)$. Conversely, suppose $a^s \equiv 1 (mod \ m)$. By the division algorithm, we have $s=q ord a +r$ where $ 0 \leq r < ord a$ thus $a^s = (a^{ord a})^q a^r \equiv a^r \equiv 1 (mod \ m)$. Hence $r=0$ since $ r < ord a$ \\
\textbf{2} We may suppose that $s \geq t$. If $a^s \equiv a^t (mod \ m)$ then $a^s=a^t a^{s-t} \equiv a^s a^{s-t} (mod \ m)$. Since $(a^s,m)=1$ it follows that $a^{s-t} \equiv 1 (mod \ m). $ which is now obvious. Conversely, if $s \equiv t ( mod \ ord a) $ then write $s = t + k ord a$ for some integer $k$. Then $a^s \equiv a^t (a^{ord a})^k \equiv a^t (mod \ m)$
\end{proof}

\begin{theorem}
Let $m$ be a positive integer and suppose that $(a,m)=1$
\begin{enumerate}
  \item If $ord a =d $ then $ord a^k = d/(k,d)$ for any $k \geq 1$
  \item If $ord a = d$ and $e$ is a positive divisor of $d$ then $a^{d/e}$ has order $e$.
\end{enumerate}
\end{theorem}

\begin{proof}
\textbf{1} From the part one of the previous theorem it follows that $(a^k)^j \equiv 1 (mod \ m)$ if and only if $kj$ is a multiple of $d$. Thus $a^k$ has order $j$ if and only if $kj$ is the smallest multiple of $k$ that is a multiple of $d$, if and only if $kj$ is the least common multiple of $k$ and $d$. But this least common multiple is $kd/(k,d)$ and hence $j = d /(k,d)$ \\
\textbf{2} This part is obvious from the fact that if $ e \mid d$ then $(d/e,d)=d/e$
\end{proof}

\chapter{Primitive roots}
\begin{definition}
Let $m$ be a positive integer and suppose that $(a,m)=1$. If the order of a modulo $m$ is $\phi(m)$ then $a$ is called a primitive root of $m$.
\end{definition}

\begin{definition}
Let $m$ be a positive integer and let $u$ be the smallest positive integer such that $a^u \equiv 1 (mod \ m)$ for every a relatively prime to $m$ . Then $u$ is called the least universal exponent for $m$.
\end{definition}

Now we will prove that every prime number must have a primitive root.

\begin{theorem}
\textbf{Legender} Every prime has a primitive root
\end{theorem}

\begin{proof}
Suppose $p$ is prime. Let $u$ be the least universal exponent for $p$ and let $g$ be an integer of order $u$ modulo $p$. Then every integer relatively prime to $p$ is a solution of the congruence $x^u \equiv 1 (mod \ p)$, so the congruence has $p-1$ solutions. But by the Lagrange's theorem, the congruence has no more than $u$ solutions. It follows that $u=p-1$ and hence $g$ is a primitive root of $p$.
\end{proof}

\begin{theorem}
If $(g,m)=1$ then $g$ is a primitive root of $m$ if and only if $ g^{\phi(m)/q} \not\equiv 1 (mod \ m)$  for every prime divisor $q$ of $\phi(m)$.
\end{theorem}

\begin{proof}
If $g$ is a primitive root of $m$, then $g^{\phi(m)/q} \not\equiv 1 (mod \ m)$ for any prime $q$, otherwise $g$ has order less than $\phi(m)$.\\
Conversely, suppose that $(g,m)=1$ and $g$ is not a primitive root of $m$. Then $g$ has order $d$ for some $ d < \phi(m)$ and $ d \mid \phi(m)$. Let $ \phi(m)=dk $ and let $q$ be a prime divisor of $k$. Then $\phi(m)/q$ is a multiple of $d$ and since $g^d \equiv 1 (mod \ m)$ it follows that $g^{\phi(m)/q} \equiv 1 (mod \ m)$.
\end{proof}

\begin{theorem}
Suppose $g$ is a primitive root of $m$. Then  $g^k$ is a primitive root of $m$ if and only if $(k,\phi(m))=1$
\end{theorem}

\begin{proof}
Since $ord g = \phi(m)$, it follows that $ord g^k = \phi(m)/(k,\phi(m))$. Thus $g^k$  will be a primitive root of $m$ i.e. $ord g^k= \phi(m)$ if and only if $ (k, \phi(m))=1$
\end{proof}

\begin{cor}
Suppose that $m$ has a primitive root. Then $m$ has exactly $\phi(\phi(m))$  incongruent primitive roots.
\end{cor}
\chapter{Power residues and indices}

\begin{definition}
Let $g$ be a primitive root of $m$ and suppose $(a,m)=1$. The smallest positive integer $i$ such that $ g^i \equiv a (mod \ m)$ is called the index of $a$ (to the base $g$) and is denoted by $ind a$.
\end{definition}
Index of $a$ behave somehow the way of logarithm which will be obvious after the next result.

\begin{theorem}
Suppose $g$ is a primitive root of $m$ and let $ind a$ denote the index of $a$ to the base $g$.
\begin{enumerate}
  \item $ind 1 \equiv 0 (mod \ \phi(m))$
  \item $a \equiv b (mod m)$ if and only if $ind a\equiv ind b (mod \ \phi(m))$
  \item $ind ab \equiv ind a + ind b ( mod \ \phi(m))$
  \item $ ind a^k \equiv k ind a (mod \ \phi(m))$ for any $k \geq 0.$
\end{enumerate}
\end{theorem}

\begin{proof}


\end{proof}

\begin{definition}
Let $m$ be a positive integer and suppose $(a,m)=1$. Then $a$ is called a $k$th power residue of $m$ if the congruence $x^k \equiv a (mod \ m )$ is solvable. If the congruence has no solutions, then $a$ is called a $k$th power nonresidue of $m$.
\end{definition}

\begin{theorem}
Let $m$ be a positive integer having a primitive root and suppose $(a,m) =1$. Then the congruence $ x^k \equiv (mod \ m)$ has a solution if and only if
$$ a^{\phi(m)/(k,\phi(m))} \equiv 1 (mod \ m)$$
If the congruence $x^k \equiv a (mod m)$ is solvable, then it has exactly $(k, \phi(m))$ incongruent solutions.
\end{theorem}

\chapter{Primitive roots in power of primes}

\begin{theorem}
Suppose that $p$ is an odd prime
\begin{enumerate}
  \item If $g$ is a primitive root of $p$ and $g^{p-1} \not\equiv 1 (mod \ p^2),$ then $g$ is a primitive root of $p^2$. If $g^{p-1} \equiv 1 (mod \ p^2),$ then $g+p$ is a primitive root of $p^2$.
  \item If $k \leq 2$ and $g$ is a primitive root of $p^k$, then $g$ is a primitive root of $p^{k+1}$.
\end{enumerate}
\end{theorem}

\begin{proof}
\textbf{1} \hspace{ .3 cm} Let $h$ be the order of $g$ modulo $p^2$, then $ h \mid \phi(p^2) = p(p-1)$. But $g^h \equiv 1 (mod \ p^2)$ implies that $g^h \equiv 1 (mod \ p)$ and since $g$ has order $p-1$ modulo $p$, $p-1$ must divide $h$. Thus $h=p-1$ or $h=p(p-1)$. If $h=p(p-1)$ then $g$ is a primitive root of $p^2$. If $h=p-1$ i.e. $g^{p-1} \equiv 1 (mod \ p^2)$, then $g$ is not a primitive root of $p^2$. We show that, in this case, $g+p$ is a primitive root of $p^2$.\\
Since $g+p$ is congruent to $g$ modulo $p$, $g+p$ is a primitive root of $p$. The preceding argument shoes that the order of $g+p$ modulo $p^2$ must divide $p-1$ of $ \phi(p^2)$. If the order is $p-1$ then $(g+p)^{p-1} \equiv (mod \ p^2)$. Using the Binomial theorem, we get
$$1 \equiv (g+p)^{p-1} \equiv g^{p-1} + (p-1) p g^{p-2} \equiv 1- pg^{p-2} (mod \ p^2)$$
Hence $ p^2 \mid p g^{p-2} $ and so $ p \mid g^{p-2}$ that is $p \mid g$, a contradiction since $(g,p)=1$. Thus the order of $g+p$ modulo $p^2$ is $\phi(p^2)$ and hence $g+p$ is a primitive root of $p^2$.

\textbf{2} \hspace{ .3 cm} Let $h$ be the order of $g$ modulo $p^{k+1}$, then $h \mid \phi(p^{k+1})=p^k(p-1)$. Because $g^h \equiv 1 (mod \ p^{k+1})$ implies $g^{h} \equiv 1 (mod \ p^k)$ and $g$ is a primitive root of $p^k$, $\phi(p^k)=p^{k-1}(p-1)$ must divide $h$. This $h=p^{k-1}(p-1)$ or $h=p^k(p-1)$. We will shoe that $ h \neq p^{k-1}(p-1)$.\\
Let $t=\phi(p^{k-1})$ then $g^t \equiv 1 (mod p^{k-1})$ by Euler's Theorem, and so $g^t = 1 +jp^{k-1}$ for some integer $j$. If $ p \mid j$ we would have $g^t \equiv 1 (mod \ p^k)$ which contradicts the fact that $g$ is primitive root of $p^k$ and therefore has order $ \phi(p^k)$ modulo $p^k$. Thus $ p \nmid j$. Since $tp=\phi(p^k)$, the Binomial theorem implies that
$$ g^{tp} = ( 1+ jp^{k-1})^{p} \equiv 1+ jp^k ( mod \ p^{k+1})$$
Thus $ g ^{ \phi(p^k)} \not\equiv 1 (mod \ p^{k+1})$ since $ p \nmid j$. Hence $h \neq p^{k-1}(p-1)$ and therefore $h=p^k(p-1)=\phi(p^{k+1})$ which proves that $g$ is a primitive root of $p^{k+1}$
\end{proof}

\chapter{Quadratic Residues}
\section{Introduction to Quadratic Residues and Nonresidues}
The question that we need to answer in this section is the
following.  If $p$ is an odd prime and $a$ is an integer relatively
prime to $p$. Is $a$ a perfect square modulo $p$. \index{Quadratic
Residue}
\begin{def1}
Let $m$ be a positive integer.  An integer $a$ is a quadratic
residue of $m$ if $(a,m)=1$ and the congruence $x^2\equiv a (mod \
m)$ is solvable. If the congruence $x^2\equiv a (mod \ m)$ has no
solution, then $a$ is a quadratic nonresidue of $m$.
\end{def1}
\index{Nonresidue}
\begin{example}
Notice that $1^2=6^2\equiv 1(mod \ 7)$, $3^2=4^2\equiv 2(mod \ 7)$
and $2^2=5^2\equiv 4(mod \ 7)$.  Thus $1,2,4$ are quadratic residues
modulo 7 while $3,5,6$ are quadratic nonresidues modulo 7.
\end{example}

\begin{lemma}
Let $p\neq 2$ be a prime number and $a$ is an integer such that
$p\nmid a$. Then either a is quadratic nonresidue modulo $p$ or
\begin{equation*}
x^2\equiv a(mod \ p)
\end{equation*}
has exactly two incongruent solutions modulo $p$.
\end{lemma}

\begin{proof}
If $x^2\equiv a(mod \ p)$ has a solution, say $x=x'$, then $-x'$ is
a solution as well.  Notice that $-x' \not\equiv x'(mod \ p)$
because then $p\mid 2x'$ and hence $p\nmid x_0$.
\par We now show that there are no more than two incongruent
solutions.  Assume that $x=x'$ and $x=x''$ are both solutions of
$x^2\equiv a(mod \ p)$.  Then we have
\begin{equation*}
(x')^2- (x'')^2=(x'+x'')(x'-x'')\equiv 0(mod \ p).
\end{equation*}
Hence
\begin{equation*}
x'\equiv x''(mod \ p)\ \ \mbox{or} \ \ x'\equiv -x''(mod \ p).
\end{equation*}
\end{proof}

The following theorem determines the number of integers that are
quadratic residues modulo an odd prime.

\begin{theorem}
If $p\neq 2$ is a prime, then there are exactly $(p-1)/2$ quadratic
residues modulo $p$ and $(p-1)/2$ quadratic nonresidues modulo $p$
in the set of integers $1,2...,p-1$.
\end{theorem}

\begin{proof}
To find all the quadratic residues of $p$ among all the integers
$1,2,...,p-1$, we determine the least positive residue modulo $p$ of
$1^2,2^2,...,(p-1)^2$. Considering the $p-1$ congruences and because
each congruence has either no solution or two incongruent solutions,
there must be exactly $(p-1)/2$ quadratic residues of $p$ among
$1,2,...,p-1$. Thus the remaining are $(p-1)/2$ quadratic
nonresidues of $p$.
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Find all the quadratic residues of 3.} \item{Find all the
quadratic residues of 13.} \item{find all the quadratic residues of
18.}\item{Show that if $p$ is prime and $p\geq 7$, then there are
always two consecutive quadratic residues of $p$.  Hint: Show that
at least one of $2,5$ or 10 is a quadratic residue of
$p$.}\item{Show that if $p$ is prime and $p\geq 7$, then there are
always two quadratic residues of $p$ that differ by 3.}
\end{enumerate}


\section{Legendre Symbol}
In this section, we define Legendre symbol which is a notation
associated to quadratic residues and prove related theorems.
\index{Legendre Symbol}
\begin{def1}
Let $p\neq 2$ be a prime and $a$ be an integer such that $p\nmid a$.
The Legendre symbol $\left(\frac{a}{p}\right)$ is defined by
\[\left(\frac{a}{p}\right)=\left\{\begin{array}{lcr}
\ 1  &\mbox{if a is a quadratic residue of p} \\
\ -1  &\mbox{if a is a quadratic nonresidue of p}. \\
\end{array}\right .\]
\end{def1}

\begin{example}
Notice that using the previous example, we see that
\begin{eqnarray*}
&&
\left(\frac{1}{7}\right)=\left(\frac{2}{7}\right)=\left(\frac{4}{7}\right)=1\\
&&
\left(\frac{3}{7}\right)=\left(\frac{5}{7}\right)=\left(\frac{6}{7}\right)=-1
\end{eqnarray*}
\end{example}
\index{Euler Criterion} In the following theorem, we present a way
to determine wether an integer is a quadratic residue of a prime.
\begin{theorem}\textbf{Euler's Criterion}\index{Euler's Criterion}
Let $p\neq 2$ be a prime and let $a$ be a positive integer such that
$p\nmid a$. Then
\begin{equation*}
\left(\frac{a}{p}\right)\equiv a^{\phi(p)/2}(mod \ p).
\end{equation*}
\end{theorem}

\begin{proof}
Assume that $\left(\frac{a}{p}\right)=1$.  Then the congruence
$x^2\equiv a(mod \ p)$ has a solution say $x=x'$.  According to
Fermat's theorem, we see that
\begin{equation*}
a^{\phi(p)/2}=((x')^2)^{\phi(p)/2}\equiv 1(mod\ p).
\end{equation*}
Now if $\left(\frac{a}{p}\right)=-1$, then $x^2\equiv a(mod \ p)$ is
not solvable. Thus by Theorem 26, we have that for each integer k
with $(k,p)=1$ there is an integer $l$ such that $kl\equiv a(mod \
p)$. Notice that $i\neq j$ since $x^2\equiv a(mod \ p)$ has no
solutions. Thus we can couple the integers $1,2,...,p-1$ into
$(p-1)/2$ pairs, each has product $a$. Multiplying these pairs
together, we find out that
\begin{equation*}
(p-1)!\equiv a^{\phi(p)/2}(mod \ p).
\end{equation*}
Using Wilson's Theorem, we get
\begin{equation*}
\left(\frac{a}{p}\right)=-1\equiv a^{(p-1)/2}(mod \ p).
\end{equation*}
\end{proof}

\begin{example}
Let $p=13$ and $a=3$.  Then $\left(\frac{3}{13}\right)=-1\equiv
3^{6}(mod \ 13).$
\end{example}

We now prove some properties of Legendre symbol.

\begin{theorem}
Let $p\neq 2$ be a prime. Let $a$ and $b$ be integers such that
$p\nmid a$, $p\nmid b$ and $p\mid (a-b)$ then
\begin{equation*}
\left(\frac{a}{p}\right)=\left(\frac{b}{p}\right).
\end{equation*}
\end{theorem}

\begin{proof}
Since $p\mid (a-b)$, then $x^2\equiv a(mod \ p)$ has a solution if
and only if $x^2\equiv b(mod \ p)$ has a solution. Hence
\begin{equation*}
\left(\frac{a}{p}\right)=\left(\frac{b}{p}\right)
\end{equation*}
\end{proof}

\begin{theorem}
Let $p\neq 2$ be a prime. Let $a$ and $b$ be integers such that
$p\nmid a$, $p\nmid b$ then
\begin{equation*}
\left(\frac{a}{p}\right)\left(\frac{b}{p}\right)=\left(\frac{ab}{p}\right)
\end{equation*}
\end{theorem}

By Euler's criterion, we have
\begin{equation*}
\left(\frac{a}{p}\right)\equiv a^{\phi(p)/2}(mod \ p)
\end{equation*}
and
\begin{equation*}
\left(\frac{b}{p}\right)\equiv b^{\phi(p)/2}(mod \ p).
\end{equation*}
Thus we get
\begin{equation*}
\left(\frac{a}{p}\right)\left(\frac{b}{p}\right) \equiv
(ab)^{\phi(p)/2}\equiv \left(\frac{ab}{p}\right)(mod \ p).
\end{equation*}
We now show when is $-1$ a quadratic residue of a prime $p$ .

\begin{cor}
If $p\neq 2$ is a, then
\[\left(\frac{-1}{p}\right)=\left\{\begin{array}{lcr}
\ 1  &{\mbox{if}\  p\equiv 1(mod \ 4)} \\
\ -1  &{\mbox{if}\  p\equiv -1(mod \ 4)}. \\
\end{array}\right .\]
\end{cor}

\begin{proof}
By Euler's criterion, we know that
\begin{equation*}
\left(\frac{a}{p}\right)=(-1)^{\phi(p)/2}(mod \ p)
\end{equation*}
If $4\mid (p-1)$, then $p=4m+1$ for some integer $m$ and thus we get
\begin{equation*}
(-1)^{\phi(p)/2}=(-1)^{2m}=1.
\end{equation*}
and if $4\mid (p-3)$, then $p=4m+3$ for some integer $m$ and we also
get
\begin{equation*}
(-1)^{\phi(p)/2}=(-1)^{2m+1}=-1.
\end{equation*}
\end{proof}

We now determine when $2$ is a quadratic residue of a prime $p$.

\begin{theorem}
For every odd prime $p$ we have
\[\left(\frac{2}{p}\right)=\left\{\begin{array}{lcr}
\ 1  &{\mbox{if}\  p\equiv \pm1(mod \ 8)} \\
\ -1  &{\mbox{if}\  p\equiv \pm 3(mod \ 8)}. \\
\end{array}\right .\]
\end{theorem}

\begin{proof}
Consider the following $(p-1)/2$ congruences
\begin{eqnarray*}
p-1&\equiv& 1(-1)^1 \ \ \ (mod \ p)\\
2&\equiv& 2(-1)^2 \ \ \ (mod \ p)\\
p-3&\equiv& 3(-1)^3 \ \ \  (mod \ p)\\
4&\equiv& 4(-1)^4 \ \ \ (mod \ p)\\
&.& \\
&.& \\
&.& \\
r&\equiv& \frac{p-1}{2}(-1)^{(p-1)/2} \ \ \ (mod \ p),\\
\end{eqnarray*}
where $r$ is either $p-(p-1)/2$ or $(p-1)/2$.  Multiplying all these
equations we get,
\begin{equation*}
2.4.6...(p-1)\equiv
\left(\frac{p-1}{2}\right)!(-1)^{1+2+...+(p-1)/2} \ \ \ (mod \ p).
\end{equation*}
This gives us
\begin{equation*}
2^{(p-1)/2}\left(\frac{p-1}{2}\right)! \equiv
\left(\frac{p-1}{2}\right)!(-1)^{(p^2-1)/8} (mod \ p).
\end{equation*}
Now notice that $\left(\frac{p-1}{2}\right)!\not\equiv 0(mod \ p)$
and thus we get
\begin{equation*}
2^{(p-1)/2}\equiv (-1)^{(p^2-1)/8}(mod \ p).
\end{equation*}
Note also that by Euler's criterion, we get
\begin{equation*}
2^{\phi(p)/2}\equiv \left(\frac{2}{p}\right)(mod \ p),
\end{equation*}
and since each member is 1 or -1 the two members are equal.
\end{proof}

\chapter{Guass Lemma}

We now present an important lemma that determines whether an integer
is a quadratic residue of a prime or not. \index{Gauss's Lemma}
\begin{lemma}\textbf{Gauss's Lemma} Let $p\neq 2$ be a prime and
$a$ a relatively prime integer to $p$.  If $k$ counts the number of
least positive residues of the integers $a, 2a,...,((p-1)/2)a$ that
are greater than $p/2$, then
\begin{equation*}
\left(\frac{a}{p}\right)=(-1)^k.
\end{equation*}
\end{lemma}

\begin{proof}
Let $m_1,m_2,...,m_s$ be those integers greater than $p/2$ in the
set of the least positive residues of the integers $a,
2a,...,((p-1)/2)a$ and let $n_1,n_2,...,n_t$ be those less than
$p/2$. We now show that
\begin{equation*}
p-m_1,p-m_2,...,p-m_k,p-n_1,p-n_2,...,p-n_t
\end{equation*}
are precisely the integers
\begin{equation*}
1,2,...,(p-1)/2,
\end{equation*}
in the same order.
\par So we shall show that no two integers of these are
congruent modulo $p$, because there are exactly $(p-1)/2$ numbers in
the set, and all are positive integers less than or equal to
$(p-1)/2$. Notice that $m_i\not\equiv m_j (\mod \ p)$ for all $i\neq
j$ and $n_i\not\equiv n_j (\mod \ p)$ for all $i\neq j$.  If any of
these congruences fail, then we will have that $r\equiv s(mod \ p)$
assuming that $ra\equiv sa(mod \ p)$. Also any of the integers
$p-m_i$ can be congruent to any of the $n_i$'s. Because if such
congruence holds, then we have $ra\equiv p-sa(mod \ p)$, so that
$ra\equiv -sa(mod \ p)$.  Because $p\nmid a$, this implies that
$r\equiv -s(mod \ p)$, which is impossible. We conclude that
\begin{equation*}
\prod_{i=1}^k(p-m_i)\prod_{i=1}^tn_i\equiv
\left(\frac{p-1}{2}\right)!(mod \ p),
\end{equation*}
which implies
\begin{equation*}
(-1)^sm_1m_2...(p-m_k)n_1n_2...n_t\equiv
\left(\frac{p-1}{2}\right)!(mod \ p),
\end{equation*}
Simplifying, we get
\begin{equation*}
m_1m_2...(p-m_k)n_1n_2...n_t\equiv a.2a...((p-1)/2)=
a^{(p-1)/2}((p-1)/2)!( mod \ p).
\end{equation*}
As a result, we have that
\begin{equation*}
a^{(p-1)/2}((p-1)/2)!\equiv ((p-1)/2)!(mod \ p)
\end{equation*}
Note that since $(p,((p-1)/2)!)=1$, we get
\begin{equation*}
(-1)^ka^{(p-1)/2}\equiv 1(mod \ p).
\end{equation*}
Thus we get
\begin{equation*}
a^{(p-1)/2}\equiv(-1)^k(mod \ p).
\end{equation*}
Using Euler's criterion, the result follows.
\end{proof}

\begin{example}
To find $\left(\frac{5}{13}\right)$ using Gauss's lemma, we
calculate
\begin{equation*}
\sum_{i=1}^6[5i/13]=[5/13]+[10/13]+[15/13]+[20/13]+[25/13]+[30/13]=5
\end{equation*}
Thus we get $\left(\frac{5}{13}\right)=(-1)^5=-1$.
\end{example}

\textbf{Exercises}
\begin{enumerate}
\item{Find all quadratic residues of 3}\item{Find all quadratic
residues of 19.}\item{Find the value of Legendre symbol
$\left(\frac{j}{7}\right)$ for $j=1,2,3,4,5,6$.}\item{Evaluate the
Legendre symbol $\left(\frac{7}{11}\right)$by using Euler's
criterion.}\item{Let $a$ and $b$ be integers not divisible by $p$.
 Show that either one or all three of the integers $a,b$ and $ab$ are quadratic residues of $p$.}
\item{Let $p$ be a prime and $a$ be a quadratic residue of $p$.
Show that if $p\equiv 1(mod \ 4)$, then $-a$ is also a quadratic
residue of $p$, whereas if $p\equiv 3(mod \ 4)$, then $-a$ is a
quadratic nonresidue of $p$.}
 \item{Show that if $p$ is an odd prime and a is an integer not
divisible by $p$ then $\left(\frac{a^2}{p}\right)=1$.}
\end{enumerate}




\chapter{Computational Lemmas for QR}

\chapter{Quadratic Reciprocity Law}

\section{The Law of Quadratic Reciprocity}
Given that $p$ and $q$ are odd primes.  Suppose we know whether $q$
is a quadratic residue of $p$ or not.  The question that this
section will answer is whether $p$ will be a quadratic residue of
$q$ or not. Before we state the law of quadratic reciprocity, we
will present a Lemma of Eisenstein which will be used in the proof
of the law of reciprocity.  The following lemma will relate Legendre
symbol to the counting lattice points in the triangle.

\begin{lemma}
If $p\neq 2$ is a prime and $a$ is an odd integer such that $p\nmid
a$, then
\begin{equation*}
\left(\frac{a}{p}\right)=(-1)^{\sum_{i=1}^{(p-1)/2}[ia/p]}.
\end{equation*}

\begin{proof}
Consider the least positive residues of the integers $a,
2a,...,((p-1)/2)a$; let $m_1,m_2,...,m_s$ be integers of this set
such that $m_i>p/2$ for all $i$ and let $n_1,n_2,...,n_t$ be those
integers where $n_i<p/2$. Using the division algorithm, we see that
\begin{equation*}
ia=p[ia/p]+r
\end{equation*}
where $r$ is one of the $m_i$ or $n_i$.  By adding the $(p-1)/2$
equations, we obtain
\begin{equation}\label{qr1}
\sum_{i=1}^{(p-1)/2}ia=\sum_{i=1}^{(p-1)/2}p[ia/p]+\sum_{i=1}^sm_i+\sum_{i=1}^tn_i.
\end{equation}
As in the proof of Gauss's Lemma, we see that
\begin{equation*}
p-m_1,p-m_2,...,p-m_s,p-n_1,p-n_2,...,p-n_t
\end{equation*}
are precisely the integers $1,2,...,(p-1)/2$, in the same order. Now
we obtain
\begin{equation}\label{qr2}
\sum_{i=1}^{(p-1)/2}i=\sum_{i=1}^s(p-m_i)+\sum_{i=1}^tn_i=ps-\sum_{i=1}^sm_i+\sum_{i=1}^tn_i.
\end{equation}
We subtract $(\ref{qr2})$ from $(\ref{qr1})$ to get
\begin{equation*}
\sum_{i=1}^{(p-1)/2}ia-\sum_{i=1}^{(p-1)/2}i=\sum_{i=1}^{(p-1)/2}p[ia/p]-ps+2\sum_{i=1}^sm_i.
\end{equation*}
Now since we are taking the following as exponents for $-1$, it
suffice to look at them modulo 2.  Thus
\begin{equation*}
0\equiv \sum_{i=1}^{(p-1)/2}[ia/p]-s(mod \ 2).
\end{equation*}
\begin{equation*}
\sum_{i=1}^{(p-1)/2}[ia/p]\equiv s(mod \ 2)
\end{equation*}
Using Gauss's lemma, we get
\begin{equation*}
\left(\frac{a}{p}\right)=(-1)^s=(-1)^{\sum_{i=1}^{(p-1)/2}[ia/p]}.
\end{equation*}
\end{proof}
\end{lemma}
\index{Quadratic Reciprocity}
\begin{theorem}\textbf{The Law of Quadratic Reciprocity}
Let $p$ and $q$ be distinct odd primes.  Then
\begin{equation*}
\left(\frac{p}{q}\right)\left(\frac{q}{p}\right)=(-1)^{\frac{p-1}{2}.\frac{q-1}{2}}
\end{equation*}
\end{theorem}

\begin{proof}
We consider now the pairs of integers also known as lattice points
$(x,y)$ with
\begin{equation*}
1\leq x\leq (p-1)/2 \mbox{and} \ \  1\leq y\leq (q-1)/2.
\end{equation*}
The number of such pairs is $\frac{p-1}{2}.\frac{q-1}{2}$. We divide
these pairs into two groups depending on the sizes of $qx$ and $py$.
Note that $qx\neq py$ for all pairs because $p$ and $q$ are distinct
primes.
\par We now count the pairs of integers $(x,y)$ with
\begin{equation*}
1\leq x\leq (p-1)/2, \ \ 1\leq y\leq (q-1)/2 \mbox{and} \ \ qx>py.
\end{equation*}
Note that these pairs are precisely those where
\begin{equation*}
1\leq x\leq (p-1)/2 \mbox{and} \ \ 1\leq y\leq qx/p.
\end{equation*}
For each fixed value of $x$ with $1\leq x\leq (p-1)/2$, there are
$[qx/p]$ integers satisfying $1\leq y\leq qx/p$. Consequently, the
total number of pairs with are
\begin{equation*}
1\leq x\leq (p-1)/2, \ \ 1\leq y\leq qx/p, \mbox{and} \ \ qx>py
\end{equation*}
is
\begin{equation*}
\sum_{i=1}^{(p-1)/2}[qi/p].
\end{equation*}
\par Consider now the pair of integers $(x,y)$ with
\begin{equation*}
1\leq x\leq (p-1)/2, \ \ 1\leq y\leq (q-1)/2, \mbox{and} \ \  qx<py.
\end{equation*}
Similarly, we find that the total number of such pairs of integers
is
\begin{equation*}
\sum_{i=1}^{(q-1)/2}[pi/q].
\end{equation*}
Adding the numbers of pairs in these classes, we see that
\begin{equation*}
\sum_{i=1}^{(p-1)/2}[qi/p]+
\sum_{i=1}^{(q-1)/2}[pi/q]=\frac{p-1}{2}.\frac{q-1}{2},
\end{equation*}
and hence using Lemma 14, we get that
\begin{equation*}
\left(\frac{p}{q}\right)\left(\frac{p}{q}\right)=(-1)^{\frac{p-1}{2}.\frac{q-1}{2}}
\end{equation*}
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Evaluate $\left(\frac{3}{53}\right)$.}\item{Evaluate
$\left(\frac{31}{641}\right)$.}\item{Using the law of quadratic
reciprocity, show that if $p$ is an odd prime, then
\[\left(\frac{3}{p}\right)=\left\{\begin{array}{lcr}
\ 1  &{\mbox{if}\  p\equiv \pm1(mod \ 12)} \\
\ -1  &{\mbox{if}\  p\equiv \pm 5(mod \ 12)}. \\
\end{array}\right .\]}\item{Show that if $p$ is an odd prime, then
\[\left(\frac{-3}{p}\right)=\left\{\begin{array}{lcr}
\ 1  &{\mbox{if}\  p\equiv 1(mod \ 6)} \\
\ -1  &{\mbox{if}\  p\equiv -1 (mod \ 6)}. \\
\end{array}\right .\]}\item{Find a congruence describing all primes for which 5 is a quadratic residue.}
\end{enumerate}

\section{Jacobi Symbol}
In this section, we define the Jacobi symbol which is a
generalization of the Legendre symbol.  The Legendre symbol was
defined in terms of primes, while Jacobi symbol will be generalized
for any odd integers and it will be given in terms of Legendre
symbol. \index{Jacobi Symbol}
\begin{definition}
Let $n$ be an odd positive integer with prime factorization
$n=p_1^{a_1}p_2^{a_2}...p_m^{a_m}$ and let $a$ be an integer
relatively prime to $n$, then
\begin{equation*}
\left(\frac{a}{n}\right)=\prod_{i=1}^m\left(\frac{a}{p_i}\right)^{c_i}.
\end{equation*}
\end{definition}

\begin{example}
Notice that from the prime factorization of 45, we get that
\begin{equation*}
\left(\frac{2}{55}\right)=\left(\frac{2}{5}\right)\left(\frac{2}{11}\right)=(-1)(-1)=1
\end{equation*}
\end{example}



\chapter{Applications of QR}

\chapter{Primes and bound on primes}
\section{The Sieve of Eratosthenes}

\begin{definition} \index{Prime Numbers}
A prime is an integer greater than 1 that is only divisible by 1 and
itself.
\end{definition}

\begin{example}
The integers 2, 3, 5, 7, 11 are prime integers.
\end{example}

Note that any integer greater than 1 that is not prime is said to be a
\textit{composite} number.\\

We now present the sieve of Eratosthenes. \index{The Sieve of
Eratosthenes} The Sieve of Eratosthenes is an ancient method of
finding prime numbers up to a specified integer.  This method was
invented by the ancient Greek mathematician Eratosthenes. There are
several other methods used to determine whether a number is prime or
composite. We first present a lemma that will be needed in the proof
of several theorems.

\begin{lemma}
Every integer greater than one has a prime divisor.
\end{lemma}

\begin{proof}
We present the proof of this Lemma by contradiction.  Suppose that
there is an integer greater than one that has no prime divisors.
Since the set of integers with elements greater than one with no
prime divisors is nonempty, then by the well ordering principle
there is a least positive integer $n$ greater than one that has no
prime divisors.  Thus $n$ is composite since $n$ divides $n$. Hence
\begin{equation*}
n=ab \mbox{with}  \ \ 1<a<n \mbox{and} \ \  1<b<n.
\end{equation*}
Notice that $a<n$ and as a result since $n$ is minimal, $a$ must
have a prime divisor which will also be a divisor of $n$.
\end{proof}

\index{Composite Integers}
\begin{theorem}
If $n$ is a composite integer, then n has a prime factor not
exceeding $\sqrt{n}$.
\end{theorem}

\begin{proof}
Since $n$ is composite, then $n=ab$, where $a$ and $b$ are integers
with $1<a\leq b<n$.  Suppose now that $a>\sqrt{n}$, then
\begin{equation*}
\sqrt{n}<a \leq b
\end{equation*}
and as a result
\begin{equation*}
ab>\sqrt{n}\sqrt{n}=n.
\end{equation*}
Therefore $a\leq \sqrt{n}$. Also, by Lemma 3, $a$ must have a prime
divisor $a_1$ which is also a prime divisor of $n$ and thus this
divisor is less than $a_1 \leq a\leq \sqrt{n}$.
\end{proof}

We now present the algorithm of the Sieve of Eratosthenes that is
used to determine prime numbers up to a given integer.\\

\textbf{The Algorithm of the Sieve of Eratosthenes}
\begin{enumerate}
\item{Write a list of numbers from 2 to the largest number $n$ you
want to test. Note that every composite integer less than $n$ must
have a prime factor less than $\sqrt{n}$. Hence you need to strike
off the multiples of the primes that are less than $\sqrt{n}$}
 \item{Strike off all multiples of 2 greater than 2 from the list . The first remaining number
in the list is a prime number.} \item{Strike off all multiples of
this number from the list.} \item{Repeat the above steps until no
more multiples are found of the prime integers that are less than
$\sqrt{n}$}
\end{enumerate}

\textbf{Exercises}
\begin{enumerate}
\item{Use the Sieve of Eratosthenes to find all primes less than
100.} \item{Use the Sieve of Eratosthenes to find all primes less
than 200.}\item{Show that no integer of the form $a^3+1$ is a prime
except for $2=1^3+1$.}\item{Show that if $2^n-1$ is prime, then $n$
is prime.  \\Hint: Use the identity
$(a^{kl}-1)=(a^{k}-1)(a^{k(l-1)}+a^{k(l-2)}+...+a^k+1)$}.
\end{enumerate}

\chapter{Fermat, Mersenne primes and perfect numbers}
\section{Perfect, Mersenne, and Fermat Numbers}

Integers with certain properties were studied extensively over the
centuries.  We present some examples of such integers and prove
theorems related to these integers and their properties.

\par We start by defining perfect numbers.
\index{Perfect Numbers}
\begin{definition}
A positive integer $n$ is called a perfect number if $\sigma(n)=2n$.
\end{definition}

In other words, a perfect number is a positive integer which is the
sum of its proper divisors.

\begin{example}
The first perfect number is 6, since $\sigma(6)=12$. You can also
view this as $6=1+2+3$. The second perfect number is 28, since
$\sigma(28)=56$ or  $28=1+2+4+7+14$.
\end{example}

The following theorem tells us which even positive integers are
perfect.

\begin{theorem}
The positive integer $n$ is an even perfect number if and only if
\begin{equation*}
n=2^{l-1}(2^l-1),
\end{equation*}
where $l$ is an integer such that $l\geq 2$ and $2^l-1$ is prime.
\end{theorem}

\begin{proof}
We show first that if $n=2^{l-1}(2^l-1)$ where $l$ is an integer
such that $l\geq 2$ and $2^l-1$ is prime then $n$ is perfect. Notice
that $2^l-1$ is odd and thus $(2^{l-1},2^l-1)=1$.  Also, notice that
$\sigma$ is a multiplicative function and thus
\begin{equation*}
\sigma(n)=\sigma(2^{l-1})\sigma(2^l-1).
\end{equation*}
Notice that $\sigma(2^{l-1})=2^l-1$ and since $ 2^l-1$ is prime we
get $\sigma(2^l-1)=2^l$.  Thus
\begin{equation*}
\sigma(n)=2n.
\end{equation*}
We now prove the converse.  Suppose that $n$ is a perfect number.
Let $n=2^rs$, where $r$ and $s$ are positive integers and $s$ is
odd. Since $(2^r,s)=1$, we get
\begin{equation*}
\sigma(n)=\sigma(2^r)\sigma(s)=(2^{r+1}-1)\sigma(s).
\end{equation*}
Since $n$ is perfect, we get
\begin{equation*}
(2^{r+1}-1)\sigma(s)=2^{r+1}s.
\end{equation*}
Notice now that $(2^{r+1}-1, 2^{r+1})=1$ and thus $2^{r+1}\mid
\sigma(s)$. Therefore there exists an integer $q$ such that
$\sigma(s)=2^{r+1}q$.  As a result, we have
\begin{equation*}
(2^{r+1}-1)2^{r+1}q=2^{r+1}s
\end{equation*}
and thus we get
\begin{equation*}
(2^{r+1}-1)q=s
\end{equation*}
So we get that $q\mid s$.  We add $q$ to both sides of the above
equation and we get
\begin{equation*}
s+q=(2^{r+1}-1)q+q=2^{r+1}q=\sigma(s).
\end{equation*}
We have to show now that $q=1$.  Notice that if $q\neq 1$, then $s$
will have three divisors and thus $\sigma(s)\geq 1+s+q$. Hence $q=1$
and as a result $s=2^{r+1}-1$.  Also notice that $\sigma(s)=s+1$.
This shows that $s$ is prime since the only divisors of $s$ are $1$
and $s$.  As a result,
\begin{equation*}
n=2^r(2^{r+1}-1),
\end{equation*}
where $(2^{r+1}-1)$ is prime.
\end{proof}

In theorem 50, we see that to determine even perfect numbers, we
need to find primes of the form $2^l-1$.  It is still unknown
whether there are odd perfect numbers or not.

\begin{theorem}
If $2^l-1$ is prime where $l$ is a positive integer, then $l$ must
be prime.
\end{theorem}

\begin{proof}
Suppose that $l$ is composite, that is $l=rs$ where $1<r<m$ and
$1<s<m$.  Thus after factoring, we get that
\begin{equation*}
2^m-1=(2^r-1)(2^{r(s-1)}+2^{r(s-2)}+...+2^{r}+1)
\end{equation*}
Notice that the two factors above are both greater than 1.  Thus
$2^m-1$ is not prime.  This is a contradiction.
\end{proof}
The above theorem motivates the definition of interesting numbers
called Mersenne numbers. \index{Mersenne Numbers} \index{Mersenne
Primes}
\begin{definition}
Let $l$ be a positive integer.  An integer of the form $M_l=2^l-1$
is called the $l$th Mersenne number; if $l$ is prime then
$M_l=2^l-1$ is called the $l$th Mersenne prime.
\end{definition}

\begin{example}
$M_3=2^3-1=7$ is the third Mersenne prime.
\end{example}

We prove a theorem that help decide whether Mersenne numbers are
prime.

\begin{theorem}
Divisors of $M_p=2^p-1$ for prime $p$ is of the form $2mp+1$, where
$m$ is a positive integer.
\end{theorem}

\begin{proof}
Let $p_1$ be a prime dividing $M_p=2^p-1$.  By Fermat's theorem, we
know that $p_1\mid (2^{p_1-1}-1)$.  Also, it is easy to see that
\begin{equation*}
(2^{p}-1,2^{p_1-1}-1)=2^{(p,p_1-1)}-1.
\end{equation*}
Since $p_1$ is a common divisor of $2^p-1$ and $2^{p_1-1}-1$ and
thus not relatively prime.  Hence $(p,p_1-1)=p$.  Hence $p\mid
(p_1-1)$ and thus there exists a positive integer $k$ such that
$p_1-1=kp$. Since $p_1$ is odd, then $k$ is even and thus $k=2m$.
Hence
\begin{equation*}
p_1=kp+1=2mp+1.
\end{equation*}
Because any divisor of $M_p$ is a product of prime divisors of
$M_p$, each prime divisor of $M_p$ is of the form $2mp+1$ and the
result follows.
\end{proof}

\begin{example}
$M_{23}=2^{23}-1$ is divisible by $47=46k+1$.  We know this by trial
and error and thus looking at all primes of the form $46k+1$ that
are less than $\sqrt{M_{23}}$.
\end{example}

We now define Fermat numbers and prove some theorems about the
properties of these numbers. \index{Fermat Numbers}
\begin{definition}
Integers of the form $F_n=2^{2^n}+1$ are called Fermat numbers.
\end{definition}

Fermat conjectured that these integers are primes but it turned out
that this is not true.  Notice that $F_0=3$, $F_1=5$, $F_2=17$,
$F_3=257$ and $F_4=65,537$ while $F_5$ is composite. It turned out
the $F_5$ is divisible by $641$.  We now present a couple of
theorems about the properties of these numbers.

\begin{theorem}
For all positive integers $n$, we have
\begin{equation*}
F_0F_1F_2...F_{n-1}=F_n-2
\end{equation*}
\end{theorem}

\begin{proof}
We will prove this theorem by induction.  For $n=1$, the above
identity is true.  Suppose now that
\begin{equation*}
F_0F_1F_2...F_{n-1}=F_n-2
\end{equation*}
holds.  We claim that
\begin{equation*}
F_0F_1F_2...F_{n}=F_{n+1}-2.
\end{equation*}
Notice that
\begin{equation*}
F_0F_1F_2...F_{n}=(F_n-2)F_n=(2^{2^n}-1)(2^{2^n}+1)=2^{2^{n+1}}-1=F_{n+1}-2.
\end{equation*}
\end{proof}
Using Theorem 53, we prove that Fermat numbers are relatively prime.

\begin{theorem}
Let $s \neq t$ be nonnegative integers.  Then $(F_s,F_t)=1$.
\end{theorem}

\begin{proof}
Assume without loss of generality that $s<t$.  Thus by Theorem 52,
we have
\begin{equation*}
F_0F_1F_2...F_s...F_{t-1}=F_t-2
\end{equation*}
Assume now that there is a common divisor $d$ of $F_s$ and $F_t$.
thus we see that $d$ divides
\begin{equation*}
F_t-F_0F_1F_2...F_s...F_{t-1}=2.
\end{equation*}
Thus $d=1$ or $d=2$.  But since $F_t$ is odd for all $t$.  We have
$d=1$. Thus $F_s$ and $F_t$ are relatively prime.
\end{proof}
\textbf{Exercises}
\begin{enumerate}
\item{Find the six smallest even perfect numbers.}\item{Find the
eighth perfect number.}\item{Find a factor of $2^{1001}-1$.}\item{We
say $n$ is abundant if $\sigma(n)>2n$. Prove that if
$n=2^{m-1}(2^m-1)$ where $m$ is a positive integer such that $2^m-1$
is composite, then $n$ is abundant.}\item{Show that there are
infinitely many even abundant numbers.}\item{Show that there are
infinitely many odd abundant numbers.}\item{Determine whether
$M_{11}$ is prime.}\item{Determine whether $M_{29}$ is
prime.}\item{Find all primes of the form $2^{2^n}+5$ where $n$ is a
nonnegative integer.}
\end{enumerate}

\chapter{Arithmetic functions and Dirichlet product} sdfsdfsadf
\section{Definitions and Properties} \index{Arithmetic Function}

\begin{definition}
An arithmetic function is a function whose domain of definition is the set $\mathbb{N}$ of positive integers.
\end{definition}
\index{Multiplicative Function}

\begin{definition}
An arithmetic function $f$ is called multiplicative if
$f(ab)=f(a)f(b)$ for all $a,b\in\mathbb{N}$ such that $(a,b)=1$.
\end{definition}

\begin{definition}
An arithmetic function $f$ is called completely multiplicative if
\begin{equation}
f(ab)=f(a)f(b)
\end{equation}
for all positive integers $a,b$.
\end{definition}
\index{Completely Multiplicative}
\begin{example}
The function $f(a)=1$ where $k$ is a completely multiplicative
function since
\begin{equation*}
f(ab)=1=f(a)f(b).
\end{equation*}
Notice also that a completely multiplicative function is a
multiplicative function but not otherwise.
\end{example}

We now prove a theorem about multiplicative functions.  We will be
interested in studying the properties of multiplicative functions
rather than the completely multiplicative ones.

\begin{theorem}
Given a multiplicative function $f$.  Let $n=\prod_{k=1}^sp_k^{a_k}$
be the prime factorization of $n$. Then
\begin{equation*}
f(n)=\prod_{k=1}^sf(p_k^{a_k}).
\end{equation*}
\end{theorem}

\begin{proof}
We prove this theorem by induction on the number of primes in the
factorization of $n$.  Suppose that $n=p_1^{a_1}$.  Thus the result
follow easily. Suppose now that for
\begin{equation*}
n=\prod_{k=1}^sp_k^{a_k},
\end{equation*}
we have
\begin{equation*}
f(n)=\prod_{k=1}^sf(p_k^{a_k}).
\end{equation*}
So we have to prove that if
\begin{equation*}
n=\prod_{k=1}^{s+1}p_k^{a_k},
\end{equation*}
then
\begin{equation*}
f(n)=\prod_{k=1}^{s+1}f(p_k^{a_k}).
\end{equation*}
Notice that for
\begin{equation*}
n=\prod_{k=1}^{s+1}p_k^{a_k},
\end{equation*}
we have $(\prod_{k=1}^{s}p_k^{a_k},p_{s+1}^{a_{s+1}})=1$. Thus we
have get
\begin{equation*}
f(n)=f(\prod_{k=1}^{s+1}p_k^{a_k})=f(\prod_{k=1}^{s}p_k^{a_k})f(p_{s+1}^{a_{s+1}})
\end{equation*}
which by the inductive step gives
\begin{equation*}
f(\prod_{k=1}^{s+1}p_k^{a_k})=f(n)=\prod_{k=1}^{s+1}f(p_k^{a_k}).
\end{equation*}
\end{proof}

From the above theorem, we can see that to evaluate a multiplicative
function at an integer, it will be enough to know the value of the
function at the primes that are in the prime factorization of the
number.

\par We now define summatory functions which represents the sum of
the values of a given function at the divisors of a given number.

\begin{definition}
Let $f$ be an arithmetic function.  Define
\begin{equation*}
F(n)=\sum_{d\mid n}f(d)
\end{equation*}
Then $F$ is called the summatory function of $f$. \index{Summatory
Function}
\end{definition}
This function determines the sum of the values of the arithmetic
function at the divisors of a given integer.
\begin{example}
If $f(n)$ is an arithmetic function, then
\begin{equation*}
F(18)=\sum_{d\mid 18}f(d)=f(1)+f(2)+f(3)+f(6)+f(9)+f(18).
\end{equation*}
\end{example}

\begin{theorem}
If $f$ is a multiplicative function, then the summatory function of
$f$ denoted by $F(n)=\sum_{d\mid n}f(d)$ is also multiplicative.
\end{theorem}

\begin{proof}
We have to prove that $F(mn)=F(m)F(n)$ whenever $(m,n)=1$.  We have
\begin{equation*}
F(mn)=\sum_{d\mid mn}f(d).
\end{equation*}
Notice that by Lemma 6, each divisor of $mn$ can be written uniquely
as a product of relatively prime divisors $d_1$ of $m$
 and $d_2$ of $n$, moreover the product of any two divisors of $m$
 and $n$ is a divisor of $mn$.  Thus we get
 \begin{equation*}
 F(mn)=\sum_{d_1\mid m, d_2\mid n}f(d_1d_2)
 \end{equation*}
 Notice that since $f$ is multiplicative, we have
 \begin{eqnarray*}
F(mn)&=& \sum_{d_1\mid m, d_2\mid n}f(d_1d_2)\\&=&\sum_{d_1\mid m,
d_2\mid n}f(d_1)f(d_2)\\&=&\sum_{d_1\mid m}f(d_1)\sum_{d_2\mid n}
f(d_2)=F(m)F(n)
 \end{eqnarray*}
\end{proof}

\textbf{Exercises}
\begin{enumerate}
\item{Determine whether the arithmetic functions $f(n)=n!$ and
$g(n)=n/2$ are completely multiplicative or not.} \item{Define the
arithmetic function $g(n)$ by the following.  g(n)=1 if $n=1$ and 0
for $n>1$. Prove that $g(n)$ is multiplicative.}
\end{enumerate}


\section{Multiplicative Number Theoretic Functions}
\par We now present several multiplicative number theoretic
functions which will play a crucial role in many number theoretic
results. We start by discussing the Euler phi-function which was
defined in an earlier chapter.  We then define the sum-of-divisors
function and the number-of-divisors function along with their
properties.

\subsection{\textbf{The Euler $\phi$-Function}}
As defined earlier, the Euler $\phi$-function counts the number of
integers smaller than and relatively prime to a given integer. We
first calculate the value of the $phi$-function at primes and prime
powers.

\begin{theorem}
If $p$ is prime, then $\phi(p)=p-1$. Conversely, if $p$ is an
integer such that $\phi(p)=p-1$, then $p$ is prime.
\end{theorem}

\begin{proof}
The first part is obvious since every positive integer less than $p$
is relatively prime to $p$.  Conversely, suppose that $p$ is not
prime.  Then $p=1$ or $p$ is a composite number.  If $p=1$, then
$\phi(p)\neq p-1$.  Now if $p$ is composite, then $p$ has a positive
divisor.  Thus $\phi(p)\neq p-1$. We have a contradiction and thus
$p$ is prime.
\end{proof}

We now find the value of $\phi$ at prime powers.

\begin{theorem}
Let $p$ be a prime and $m$ a positive integer, then
$\phi(p^m)=p^m-p^{m-1}$.
\end{theorem}

\begin{proof}
Note that all integers that are relatively prime to $p^m$ and that
are less than $p^m$ are those that are not multiple of $p$. Those
integers are $p,2p,3p,...,p^{m-1}p$.  There are $p^{m-1}$ of those
integers that are not relatively prime to $p^m$ and that are less
than $p^m$.  Thus
\begin{equation*}
\phi(p^m)=p^m-p^{m-1}.
\end{equation*}
\end{proof}

\begin{example}
$\phi(7^3)=7^3-7^2=343-49=294$.  Also $\phi(2^{10})=2^{10}-2^9=512.$
\end{example}

We now prove that $\phi$ is a multiplicative function.

\begin{theorem}
Let $m$ and $n$ be two relatively prime positive integers.  Then
$\phi(mn)=\phi(m)\phi(n)$.
\end{theorem}

\begin{proof}
Denote $\phi(m)$ by $s$ and let $k_1,k_2,...,k_s$ be a reduced
residue system modulo $m$.  Similarly, denote $\phi(n)$ by $t$ and
let $k_1',k_2',...,k_t'$ be a reduced residue system modulo $n$.
Notice that if $x$ belongs to a reduced residue system modulo $mn$,
then
\begin{equation*}
(x,m)=(x,n)=1.
\end{equation*}
Thus
\begin{equation*}
x\equiv k_i(mod\ m) \mbox{and} \ \  x\equiv k_j'(mod \ n)
\end{equation*}
for some $i,j$. Conversely, if
\begin{equation*}
x\equiv k_i(mod\ m) \mbox{and} \ \  x\equiv k_j'(mod \ n)
\end{equation*}
some $i,j$ then $(x,mn)=1$ and thus $x$ belongs to a reduced residue
system modulo $mn$. Thus a reduced residue system modulo $mn$ can be
obtained by by determining all $x$ that are congruent to $k_i$ and
$k_j'$ modulo $m$ and $n$ respectively.  By the Chinese remainder
theorem, the system of equations
\begin{equation*}
x\equiv k_i(mod\ m) \mbox{and} \ \  x\equiv k_j'(mod \ n)
\end{equation*}
has a unique solution. Thus different $i$ and $j$ will yield
different answers. Thus $\phi(mn)=st$.
\end{proof}

We now derive a formula for $\phi(n)$.

\begin{theorem}
Let $n=p_1^{a_1}p_2^{a_2}...p_s^{a_s}$ be the prime factorization of
$n$.  Then
\begin{equation*}
\phi(n)=n\left(1-\frac{1}{p_1}\right)\left(1-\frac{1}{p_2}\right)...\left(1-\frac{1}{p_s}\right).
\end{equation*}
\end{theorem}

\begin{proof}
By Theorem 37, we can see that for all $1\leq i\leq k$
\begin{equation*}
\phi(p_i^{a_i})=p_i^{a_i}-p_i^{a_i-1}=p_i^{a_i}\left(1-\frac{1}{p_i}\right).
\end{equation*}
Thus by Theorem 38,
\begin{eqnarray*}
\phi(n)&=&\phi(p_1^{a_1}p_2^{a_2}...p_s^{a_s})\\&=&
\phi(p_1^{a_1})\phi(p_2^{a_2})...\phi(p_s^{a_s})\\&=&p_1^{a_1}\left(1-\frac{1}{p_1}\right)
p_2^{a_2}\left(1-\frac{1}{p_2}\right)...p_s^{a_s}\left(1-\frac{1}{p_s}\right)\\&=&
p_1^{a_1}p_2^{a_2}...p_k^{a_k}\left(1-\frac{1}{p_1}\right)\left(1-\frac{1}{p_2}\right)...
\left(1-\frac{1}{p_s}\right)\\&=&
n\left(1-\frac{1}{p_1}\right)\left(1-\frac{1}{p_2}\right)...\left(1-\frac{1}{p_s}\right).
\end{eqnarray*}
\end{proof}

\begin{example}
Note that
\begin{equation*}
\phi(200)=\phi(2^35^2)=200\left(1-\frac{1}{2}\right)\left(1-\frac{1}{5}\right)=80.
\end{equation*}
\end{example}

\begin{theorem}
Let $n$ be a positive integer greater than 2.  Then $\phi(n)$ is
even.
\end{theorem}

\begin{proof}
Let $n=p_1^{a_1}p_2^{a_2}...p_k^{a_k}$.  Since $\phi$ is
multiplicative, then
\begin{equation*}
\phi(n)=\prod_{j=1}^k\phi(p_j^{a_j}).
\end{equation*}
Thus by Theorem 39, we have
\begin{equation*}
\phi(p_j^{a_j})=p_j^{a_j-1-1}(p_j-1).
\end{equation*}
We see then $\phi(p_j^{a_j})$is even if $p_j$ is an odd prime.
Notice also that if $p_j=2$, then it follows that $\phi(p_j^{a_j})$
is even.  Hence $\phi(n)$ is even.
\end{proof}

\begin{theorem}
Let $n$ be a positive integer.  Then
\begin{equation*}
\sum_{d\mid n}\phi(d)=n.
\end{equation*}
\end{theorem}

\begin{proof}
Split the integers from 1 to $n$ into classes.  Put an integer $m$
in the class $C_d$ if the greatest common divisor of $m$ and $n$
is $d$.  Thus the number of integers in the $C_d$ class is the
number of positive integers not exceeding $n/d$ that are relatively
prime to n/d.  Thus we have $\phi(n/d)$ integers in $C_d$.  Thus we
see that
\begin{equation*}
n=\sum_{d\mid n}\phi(n/d).
\end{equation*}
As $d$ runs over all divisors of $n$, so does $n/d$.  Hence
\begin{equation*}
n=\sum_{d\mid n}\phi(n/d)=\sum_{d\mid n}\phi(d).
\end{equation*}
\end{proof}

\subsection{\textbf{The Sum-of-Divisors Function}}
The sum of divisors function, denoted by $\sigma(n)$, is the sum of
all positive divisors of $n$. \index{The Sum of Divisors Function}
\begin{example}
$\sigma(12)=1+2+3+4+6+12=28.$
\end{example}

Note that we can express $\sigma(n)$ as $\sigma(n)=\sum_{d\mid n}d$.
\par We now prove that $\sigma(n)$ is a multiplicative function.

\begin{theorem}
The sum of divisors function $\sigma(n)$ is multiplicative.
\end{theorem}

\begin{proof}
We have proved in Theorem 35 that the summatory function is
multiplicative once $f$ is multiplicative.  Thus let $f(n)=n$ and
notice that $f(n)$ is multiplicative.  As a result, $\sigma(n)$ is
multiplicative.
\end{proof}

Once we found out that $\sigma(n)$ is multiplicative, it remains to
evaluate $\sigma(n)$ at powers of primes and hence we can derive a
formula for its values at any positive integer.

\begin{theorem}
Let $p$ be a prime and let $n=p_1^{a_1}p_2^{a_2}...p_t^{a_t}$ be a
positive integer. Then
\begin{equation*}
\sigma(p^a)=\frac{p^{a+1}-1}{p-1},
\end{equation*}
and as a result,
\begin{equation*}
\sigma(n)=\prod_{j=1}^{t}\frac{p_j^{a_j+1}-1}{p_j-1}
\end{equation*}
\end{theorem}

\begin{proof}
Notice that the divisors of $p^{a}$ are $1,p,p^2,...,p^a$. Thus
\begin{equation*}
\sigma(p^a)=1+p+p^2+...+p^a=\frac{p^{a+1}-1}{p-1}.
\end{equation*}
where the above sum is the sum of the terms of a geometric
progression.
\par Now since $\sigma(n)$ is multiplicative, we have
\begin{eqnarray*}
\sigma(n)&=&\sigma(p^{a_1})\sigma(p^{a_2})...\sigma(p^{a_t})\\&=&
\frac{p_1^{a_1+1}-1}{p_1-1}.\frac{p_2^{a_2+1}-1}{p_2-1}...\frac{p_t^{a_t+1}-1}{p_t-1}\\
&=&\prod_{j=1}^{t}\frac{p_j^{a_j+1}-1}{p_j-1}
\end{eqnarray*}
\end{proof}

\begin{example}
$\sigma(200)=\sigma(2^35^2)=\frac{2^4-1}{2-1}\frac{5^3-1}{5-1}=15.31=465.$
\end{example}

\subsection{\textbf{The Number-of-Divisors Function}}
The number of divisors function, denoted by $\tau(n)$, is the sum of
all positive divisors of $n$. \index{The Number of Divisor Function}
\begin{example}
$\tau(8)=4.$
\end{example}

We can also express $\tau(n)$ as $\tau(n)=\sum_{d\mid n}1$.
\par We can also prove that $\tau(n)$ is a multiplicative function.

\begin{theorem}
The number of divisors function $\tau(n)$ is multiplicative.
\end{theorem}

\begin{proof}
By Theorem 36, with $f(n)=1$, $\tau(n)$ is multiplicative.
\end{proof}

We also find a formula that evaluates $\tau(n)$ for any integer $n$.

\begin{theorem}
Let $p$ be a prime and let $n=p_1^{a_1}p_2^{a_2}...p_t^{a_t}$ be a
positive integer. Then
\begin{equation*}
\tau(p^a)=a+1,
\end{equation*}
and as a result,
\begin{equation*}
\tau(n)=\prod_{j=1}^{t}(a_j+1).
\end{equation*}
\end{theorem}

\begin{proof}
The divisors of $p^{a}$ as mentioned before are $1,p,p^2,...,p^a$.
Thus
\begin{equation*}
\tau(p^a)=a+1
\end{equation*}
\par Now since $\tau(n)$ is multiplicative, we have
\begin{eqnarray*}
\tau(n)&=&\tau(p^{a_1})\tau(p^{a_2})...\tau(p^{a_t})\\&=&
(a_1+1)(a_2+1)...(a_t+1)\\
&=&\prod_{j=1}^{t}(a_j+1).
\end{eqnarray*}
\end{proof}

\begin{example}
$\tau(200)=\tau(2^35^2)=(3+1)(2+1)=12$.
\end{example}

\textbf{Exercises}
\begin{enumerate}
\item{Find $\phi(256)$ and $\phi(2.3.5.7.11)$.} \item{Show that
$\phi(5186)=\phi(5187)$.}\item{Find all positive integers $n$ such
that $\phi(n)=6$.}\item{Show that if $n$ is a positive integer, then
$\phi(2n)=\phi(n)$ if $n$ is odd.} \item{Show that if $n$ is a
positive integer, then $\phi(2n)=2\phi(n)$ if $n$ is
even.}\item{Show that if $n$ is an odd integer, then
$\phi(4n)=2\phi(n)$.}\item{Find the sum of positive integer divisors
and the number of positive integer divisors of 35}\item{Find the sum
of positive integer divisors and the number of positive integer
divisors of $2^53^45^37^313$}.\item{Which positive integers have an
odd number of positive divisors.}\item{Which positive integers have
exactly two positive divisors.}
\end{enumerate}



\chapter{Abelian group of arithmetic functions}

\begin{theorem}
If $f$ and $g$ are multiplicative functions then their Dirichlet product $f \ast g$ is also muliplicative.
\end{theorem}

\begin{proof}
Let $h= f \ast g $ and choose relatively prime integers $m$ and $n$. Then
$$h(mn) = \sum_{c \mid mn} f(c) g \left( \frac{mn}{c} \right) $$
Now every divisor $c$ of $mn$ be expressed in the form $c=ab$ where $ a \mid m$ and $ b \mid n$. Moreover, $(a,b)=1$ and
$(m/a, n/b) =1$ and there is one one correspondence between the set of products $ab$ and the divisors $c$ of $mn$.\\
Hence
$$h(mn)=\sum_{a \mid m , b \mid n} f(ab) g \left( \frac{mn}{ab} \right)= \sum_{a \mid m , b \mid n} f(a)f(b) g \left( \frac{m}{a} \right) g \left( \frac{n}{b} \right)$$
$$ \sum_{ a \mid m } f(a) g \left( \frac{m}{a} \right)\sum_{b \mid n} f(b) g \left( \frac{n}{b} \right) = h(m) h(n)$$
Which completes the  proof.
\end{proof}

We now want to show that the inverse of a multiplicative function is again multiplicative. We prove this fact undirectly, first proving the following result and then concluding it as a corollary.

\begin{theorem}
If both $g$ and $ f \ast g$ are multiplicative, then $f$ is also multiplicative.
\end{theorem}

\begin{proof}
We shall assume that $f$ is not multiplicative and deduce that $f \ast g$ is also not multiplicative. Let $ h = f \ast g$.
Since $f$ is not multiplicative there exist positive integers $m$ and $n$  with $(m,n)=1$ such that
$$ f(mn) \neq f(m) f(n) .$$
We choose such a pair $m$ and $n$  for which the product $mn$ is as small as possible. If $mn=1$ then $f(1) \neq f(1)f(1) $
so $f(1) \neq 1 $. Since $ h(1) =f(1)g(1)=f(1) \neq 1$ this shows that $h$ is not multiplicative.\\
If $mn > 1$ then we have $f(ab) =f(a)f(b)$ for all positive integers $a, b$ with $(a,b)=1$ and $ab < mn$.
$$h(mn)= \sum_{ a \mid m , b \mid n , ab <mn} f(ab) g \left( \frac{mn}{ab} \right) + f(mn) g(1)= \sum_{ a \mid m , b \mid n , ab <mn} f(a)f(b)g \left( \frac{m}{a} \right) g \left( \frac{n}{b} \right) +f(mn) $$
$$= \sum_{a \mid m } g \left( \frac{m}{a} \right) \sum_{b \mid n} f(b) g \left( \frac{n}{b} \right) -f(m)f(n) + f(mn)$$
$$=h(m)h(n)-f(m)f(n)+f(mn)$$
Since $f(m)f(n) \neq f(mn)$ this shows that $h(mn) \neq h(m)h(n)$ which proves the contrapositive statement hence the result.
\end{proof}

Now we will show that the inverse of multiplicative function is multiplicative.

\begin{cor}
If $g$ is multiplicative then $g^{-1}$ is also multiplicative.
\end{cor}

\begin{proof}
We know $g$ and $I= g \ast g^{-1}$ are two multiplicative functions. Using above theorem, for $f = g^{-1}$, we have the result.
\end{proof}.
\section{Abelian group}
This gives the following result

\begin{theorem}
The set of all multiplicative functions forms a subgroup of the group of all arithmetical fucntions.
\end{theorem}

\begin{proof}
It is obvious from the previous two results, as to prove a subset, a subgroup we need to show only $ab$ in the set $ a ^{-1}$ which we have proved.
\end{proof}

\section{The Mobius Function and the Mobius Inversion Formula}
We start by defining the Mobius function which investigates integers
in terms of their prime decomposition.  We then determine the Mobius
inversion formula which determines the values of the a function $f$
at a given integer in terms of its summatory function.

\begin{definition}
$\mu(n)=\left\{\begin{array}{lcr}
\ 1   \ \  \mbox{if}\ \  n=1;\\
\ (-1)^t  \ \  \mbox{if}\ \  n=p_1p_2...p_t \ \  \mbox{where the}\ \  p_i \ \   \mbox{are distinct primes};\\
\ 0   \ \  \mbox{ otherwise}.\\
\end{array}\right .\ $
\end{definition}

Note that if $n$ is divisible by a power of a prime higher than
one then $\mu(n)=0$.

In connection with the above definition, we have the following
\index{Square-Free}
\begin{definition}
An integer $n$ is said to be \bf{square-free}, if no square divides it, i.e. if there does not exist an integer $k$
such that $k^2\mid n$.
\end{definition}

It is immediate (prove as exercise) that the prime-number
factorization of a square-free integer contains only distinct
primes.

\begin{example}
Notice that $\mu(1)=1$, $\mu(2)=-1$, $\mu(3)=-1$ and $\mu(4)=0$.
\end{example}

We now prove that $\mu(n)$ is a multiplicative function.
\index{Mobius Function}
\begin{theorem}
The Mobius function $\mu(n)$ is multiplicative.
\end{theorem}

\begin{proof}
Let $m$ and $n$ be two relatively prime integers.  We have to prove
that
\begin{equation*}
\mu(mn)=\mu(m)\mu(n).
\end{equation*}
If $m=n=1$, then the equality holds. Also, without loss of
generality, if $m=1$, then the equality is also obvious.  Now
suppose that $m$ or $n$ is divisible by a power of prime higher than
1, then
\begin{equation*}
\mu(mn)=0=\mu(m)\mu(n).
\end{equation*}
What remains to prove that if $m$ and $n$ are square-free integers
say $m=p_1p_2...p_s$ where $p_1,p_2,...,p_s$ are distinct primes and
$n=q_1q_2...q_t$ where $q_1,q_2,...,q_t$.  Since $(m,n)=1$, then
there are no common primes in the prime decomposition between $m$
and $n$.  Thus
\begin{equation*}
\mu(m)=(-1)^s, \mu(n)=(-1)^t \mbox{and} \ \  \mu(mn)=(-1)^{s+t}.
\end{equation*}
\end{proof}

In the following theorem, we prove that the summatory function of
the Mobius function takes only the values $0$ or $1$.

\begin{theorem}
Let $F(n)=\sum_{d\mid n}\mu(d)$, then $F(n)$ satisfies
\begin{equation*}
F(n)=\left\{\begin{array}{lcr}
\ 1   \ \  \mbox{if}\ \  n=1;\\
\ 0  \ \  \mbox{if}\ \  n>1.\\
\end{array}\right .\
\end{equation*}
\end{theorem}

\begin{proof}
For $n=1$, we have $F(1)=\mu(1)=1$. Let us now find $\mu(p^k)$ for
any integer $k>0$.  Notice that
\begin{equation*}
F(p^k)=\mu(1)+\mu(p)+...+\mu(p^k)=1+(-1)+0+...+0=0
\end{equation*}
Thus by Theorem 36, for any integer
$n=p_1^{a_1}p_2^{a_2}...p_t^{a_t}>1$ we have,
\begin{equation*}
F(n)=F(p_1^{a_1})F(p_2^{a_2})...F(p_t^{a_t})=0
\end{equation*}
\end{proof}

We now define the Mobius inversion formula.  The Mobius inversion
formula expresses the values of $f$ in terms of its summatory
function of $f$. \index{Mobius Inversion Formula}
\begin{theorem}
Suppose that $f$ is an arithmetic function and suppose that $F$ is
its summatory function, then for all positive integers $n$ we have
\begin{equation*}
f(n)=\sum_{d\mid n}\mu(d)F(n/d).
\end{equation*}
\end{theorem}

\begin{proof}
We have
\begin{eqnarray*}
\sum_{d\mid n}\mu(d)F(n/d)&=&\sum_{d\mid n}\mu(d)\sum_{e\mid
(n/d)}f(e)\\ &=& \sum_{d\mid n}\sum_{e\mid
(n/d)}\mu(d)f(e)\\&=&\sum_{e\mid n}\sum_{d\mid
(n/e)}\mu(d)f(e)\\&=&\sum_{e\mid n}f(e)\sum_{d\mid
(n/d)}\mu(d)\\
\end{eqnarray*}
Notice that $\sum_{d\mid (n/e)}\mu(d)=0$ unless $n/e=1$ and thus
$e=n$.  Consequently we get
\begin{equation*}
\sum_{e\mid n}f(e)\sum_{d\mid (n/d)}\mu(d)=f(n).1=f(n).
\end{equation*}
\end{proof}

\begin{example}
A good example of a Mobius inversion formula would be the inversion
of $\sigma(n)$ and $\tau(n)$.  These two functions are the summatory
functions of $f(n)=n$ and $f(n)=1$ respectively. Thus we get
\begin{equation*}
n=\sum_{d\mid n}\mu(n/d)\sigma(d)
\end{equation*}
and
\begin{equation*}
1=\sum_{d\mid n}\mu(n/d)\tau(d).
\end{equation*}
\end{example}

\textbf{Exercises}
\begin{enumerate}
\item{Find $\mu(12)$, $\mu(10!)$ and $\mu(105)$.}\item{Find the
value of $\mu(n)$ for each integer $n$ with $100\leq n\leq
110$.}\item{Use the Mobius inversion formula and the identity
$n=\sum_{d\mid n}\phi(n/d)$ to show that $\phi(p^t)=p^t-p^{t-1}$
where $p$ is a prime and $t$ is a positive integer.}
\end{enumerate}



\chapter{Bell Series of Arithmetic Functions}

E. T. Bell use formal power series to study the properties of multiplicative arithmetical functioins

\begin{definition}
Given an arithmetical function $f$  and a prime $p$, we denote by $f_p(x)$ the formal power series
$$ f_{p}(x) = \sum_{n=0}^{\infty} f(p^n) x ^n $$
and call this the Bell series of $f$.
\end{definition}

\begin{theorem}
\textbf{Uniqueness Theorem} Let $f$ and $g $ be multiplicative functions. Then $f =g$ if and only if
$$f_p(x) = g_p(x)$$
\end{theorem}

\begin{proof}
If $f=g$ then they must agree on all the integers and in particular to the prime powers, i,e, $f(p^n)=g(p^n)$ for all $p$
and all $n \geq 0$ so $f_p(x)=g_p(x)$.\\
Conversely, if $f_p(x)=g_p(x)$j for all $p$ then $f(p^n)=g(p^n)$ for all $n \geq 0$. Since $f$ and $g$ are multiplicative and agree at all prime powers they agree at all the positive integers by using the Fundamentel Theorem of Arithemtics. so $f=g$.
\end{proof}

Consider some examples.
\begin{example}
The Bell series of Mobius function is very simple as the $\mu (p^n) =0 $ for $n \geq 2$. So we have
$$ \mu_p(x) = 1-x$$
\end{example}

\begin{example}
Consider the Euler $\phi$ function. we know that for the prime powers we have $\phi(p^k) = p^k - p^{k-1}$.
$$\phi_p(x)= 1 + \sum_{n=1}^{\infty} (p^n - p^{n-1})x^n= (1-x) \sum_{n=0}^{\infty}p^n x^n= \frac{1-x}{1-px}$$
\end{example}


\begin{example}
\textbf{Completely multiplicative functions} If $f$ is completely multiplicative function then $f(p^a)=f(p)^a$ for all $a \geq 0$ so the Bell series is a geometric series of the following form.

$$ f_p(x)= \sum_{n=0}^{\infty} f(p)^n x^n= \frac{1}{1-f(p)x}$$
\end{example}

\section{Bell series and Dirichlet product}

\begin{theorem}
For any two arithmetical functions $f$ and $g$ and for every prime $p$ we have
$$ (f \ast g)_p(x)= f_p(x) g_p(x)$$
\end{theorem}

\begin{proof}
Since the divisors of $p^n$  are $1,p,p^2,\ldots,p^n$ we have

$$(f \ast g)(p^n) = \sum_{d \mid p^n} f(d) g\left( \frac{p^{n}}{d} \right) = \sum_{k = 0}^{ \infty} f(p^{k}) g(p^{n-k})$$

The last term above is exactly the coefficient of $n$th term when two series are multiplied, this simple fact conclude the theorem.
\end{proof}

\begin{example}
Let $f(n)=2 ^{v(n)}$ where $v(1)=1$ and $v(n)=k$ if $ n=p_{1}^{\alpha_1} p_{2}^{\alpha_2} \ldots p_{k}^{\alpha_k}.$ Now we consider the Bell series of the function $f$ and try to construct the relation with Dirichlet product.
$$f_p(x)= 1 + \sum_{n=1}^{\infty} 2^{v(p^n)}x^n =1 + \sum_{n=1}^{\infty}2x^n= 1 + \frac{2x}{1-x}=\frac{1+x}{1-x}$$
Hence
$$f_p(x)= \mu_{P}^{2}(x)u_p(x)$$
which implies $f= \mu^{2} \ast u$ or
$$ 2^{v(n)}= \sum_{ d \mid n} \mu^2(d) $$
\end{example}

\chapter{Derivation of Arithmetic functions}

\begin{definition}
For any arithmetical function $f$ we define its derivative $f^{'}$ to be the arithmetical function given by the equation
$$ f^{'}(n)=f(n) \log n$$
for $n \geq 1$
\end{definition}

\begin{example}
Since $I(n)\log n =0$ for all $n$ we have $ I^{'} =0$. Since $u(n)=1$ for all $n$ we have $ u^{'}(n)= \log n$. Hence the formula
$ \sum_{d \mid n} \Lambda(d) = \log n$ can be written as
$$ \Lambda \ast u = u^{'} $$
\end{example}

This definition of derivation is not as we discussed in Calculus, which is the rate of change but still it share many properties of the derivation as the sum and product rule which we discussed in our next result.

\begin{theorem}
If $f$ and $g$ are arithmetical functions we have
\begin{enumerate}
  \item $(f+g)^{'}=f^{'}+g^{'}$
  \item $(g \ast g)^{'} = f^{'} \ast g + f \ast g^{'}$
\end{enumerate}

\end{theorem}

\begin{proof} The first part is very simple and the following shows it
$$(f+g)^{'}=(f+g)(n) \log n =f(n) \log n + g(n) \log n = f^{'} + g^{'}$$
To prove the second we use the identity $ \log n = \log d + \log (n/d)$ and write
$$ (f \ast g)^{'}= \sum_{d \mid n} f(d) g \left( \frac{n}{d} \right) \log n$$
$$= \sum_{d \mid n} f(d) \log d g \left( \frac{n}{d} \right) + \sum_{d \mid n} f(d) g \left( \frac{n}{d} \right) \log \left( \frac{n}{d} \right)$$
$$= (f^{'} \ast g) + (f \ast g^{'})$$
\end{proof}
\section{Selberg Identity}

Using the concept if derivative we can quickly derive the Selberg identity which is very important for the modern proof of prime number theorem.

\begin{theorem}
for $n \geq 1$ we have
$$ \Lambda(n) \log n + \sum_{d \mid n} \Lambda(d) \Lambda \left( \frac{n}{d} \right)= \sum_{d \mid n} \mu(d) \log^{2} \frac{n}{d} $$
\end{theorem}

\begin{proof}
We know some identities which are $\Lambda \ast u = u ^{'}$ and $ \mu = u^{-1}$. We start with the first identity and differentiate both sides by using the previous theorem.
$$\Lambda^{'} \ast u + \Lambda \ast u^{'} = u^{''}$$
Again put $\Lambda \ast u = u ^{'}$ in the above identity
$$\Lambda^{'} \ast u + \Lambda \ast (\Lambda \ast u)  = u^{''}$$
Now we multiply on both sides $\mu$ which is the inverse of $u$ and get
$$ \Lambda^{'} + \Lambda \ast \Lambda = u^{''} \ast \mu $$
which is the required identity.
\end{proof}

\chapter{Big O and small o notations}

We will explain the definitions and some examples of the notations.

\section{The function $[x]$ , the symbols "O", "o" and  "$\sim$"}
We start this section by introducing an important number theoretic
function.  We proceed in defining some convenient symbols that will
be used in connection with the growth and behavior
of some functions that will be defined in later chapters.  \\


\subsection{The Function $[x]$}. \index{The Function [x]}
\begin{definition}
The function $[x]$ represents the largest integer not exceeding $x$.
In other words, for real $x$, $[x]$ is the unique integer such that
\begin{equation*}
x-1<[x]\leq x<[x]+1.
\end{equation*}
\end{definition}

We also define $((x))$ to be the fractional part of $x$.  In other
words $((x))=x-[x]$. \\
We now list some properties of $[x]$ that will be used in later or
in more advanced courses in number theory.
\begin{enumerate}
\item{$[x+n]=[x]+n$, if $n$ is an integer.} \item{$[x]+[y]\leq
[x+y]$.} \item{$[x]+[-x]$ is 0 if $x$ is an integer and -1
otherwise.} \item{The number of integers $m$ for which $x<m\leq y$
is $[y]-[x]$.} \item{The number of multiples of $m$ which do not
exceed $x$ is $[x/m]$.}
\end{enumerate}

Using the definition of $[x]$, it will be easy to see that the
above properties are direct consequences of the definition.\\
We now define some symbols that will be used to estimate the growth
of number theoretic functions.  These symbols will be not be really
appreciated in the context of this book but these are often used in
many analytic proofs.

\subsection{The "O" and "o" Symbols}

\par Let $f(x)$ be a positive function and let $g(x)$ be any function.  Then $O(f(x))$
(pronounced "big-oh" of $f(x)$)denotes the collection of functions $g(x)$ that exhibit a growth that
is limited to that of $f(x)$ in some respect. The traditional notation
for stating that $g(x)$ belongs to this collection is:
\begin{equation*}
g(x)=O(f(x)).
\end{equation*}
This means that for sufficiently large $x$,
\begin{equation}
\frac{\mid g(x)\mid }{|f(x)|}<M,
\end{equation}
where $M$ is some positive number.


\begin{example}
$\sin (x)=O(x)$, and also $\sin(x)=O(1)$.
\end{example}
\index{small-oh} Now, the relation $g(x)=o(f(x))$, pronounced
"small-oh" of $f(x)$, is used to indicate that $f(x)$ grows much
faster than $g(x)$.  It formally says that
\begin{equation}
\lim_{x\rightarrow \infty}\frac{g(x)}{f(x)}=0.
\end{equation}
More generally, $g(x)=o(f(x))$ at a point $b$ if
\begin{equation}
\lim_{x\rightarrow b}\frac{g(x)}{f(x)}=0.
\end{equation}

\begin{example}
$\sin(x)=o(x)$ at $\infty$, and $x^k=o(e^x)$ also at $\infty$ for every constant $k$.
\end{example}

The notation that $f(x)$ is asymptotically \index{asymptotic}equal
to $g(x)$ is denoted by $\sim$.  Formally speaking, we say that
$f(x) \sim g(x)$ if

\begin{equation}
\lim_{x\rightarrow \infty}\frac{f(x)}{g(x)}=1.
\end{equation}

\begin{example}
$[x] \sim x$.
\end{example}

The purpose of introducing these symbols is to make complicated
mathematical expressions simpler.  Some expressions can be
represented as the principal part that you need plus a remainder
term.  The remainder term can be expressed using the above
notations.  So when you need to combine several expressions, the
remainder parts involving these symbols can be easily combined. We
will state now some properties of the above symbols without proof.
These properties are easy to prove using the definitions of the
symbols.
\begin{enumerate}
\item{$O(O(f(x)))=O(f(x))$,}\item{$o(o(f(x)))=o(f(x))$.}
\item{$O(f(x))\pm O(f(x))=O(f(x))$,} \item{$o(f(x)\pm
o(f(x))=o(f(x))$,} \item{$O(f(x))\pm O(g(x))=O(\max(f(x), g(x)))$,}
\end{enumerate}
There are some other properties that we did not mention here,
properties that are rarely used in number theoretic proofs.\\
\textbf{Exercises}
\begin{enumerate}
\item{Prove the five properties of the $[x]$}
\item{Prove the five properties of the $O$ and $o$ notations in Example 24.}
\end{enumerate}




\chapter{Euler Summation Formula}

\section{Euler Summation Formula}

\begin{theorem}

\textbf{Euler Summation Formula} If $f$ has continuous derivative $f^{'}$ on the interval $[y,x]$ where $y > 0$ then
$$\sum_{y < n \leq x} f(n) = \int_{y}^{x} f(t) dt + \int_{y}^{x} (t- [t]) f^{'}(t)dt+f(x)([x]-x)-f(y)([y]-y)$$
\end{theorem}

\begin{proof}
Let $m=[y]$ and $k=[y]$. For integers $n$ and $n-1$ in $[y,x]$ we have
$$ \int_{n-1}^{n} f^{'}(t) dt= \int_{n-1}^{n} (n-1) f^{'}(t) dt= (n-1) \{ f(n) - f(n-1) \}$$
$$ = \{ n f(n) - (n-1) f(n-1) \} -f(n) \}$$
Summing from $n=m+1$ to $n=k$ we have
$$\int_{m}{k} [t] f^{'}(t)dt= \sum_{n=m+1}^{k} \{ n f(n) - (n-1) f(n-1) \} - \sum_{y < n \leq x} f(n) $$
$$ = kf(k) -mf(m) -  \sum_{y < n \leq x} f(n) $$
Which implies

$$\sum_{y < n \leq x} f(n) = - \int_{m}^{k} f^{'}(t)dt + k f(k) -m f(m)$$

\begin{equation}
= - \int_{m}^{k} f^{'}(t)dt + k f(x) -m f(y)
\end{equation}

Now simply integerate the integral by parts and get
\begin{equation}
\int_{y}^{x} f(t) dt= xf(x) -yf(y) - \int_{y}^{x} t f^{'}(t) dt
\end{equation}
Now subtracting the above two equations we get the desired result.
\end{proof}

\subsection{ sum of the form $\sum_{n \leq x}$}
We normally apply the Euler summation formula for the sum of type $\sum_{n \leq x}$ where $n$ runs on the integers.
Obviously $n$ takes the value $1$. If we revisit the statement of Euler summation formula, the interval $[y,x]$ can be replace with $[1,x]$. In this case we have
$$\sum_{n \leq x} f(n) = \sum_{ 1 < n \leq x} f(n) + f(1) $$.

\begin{cor}
If $f$ has continuous derivative $f^{'}$ on the interval $[1,x]$ then
$$\sum_{1 < n \leq x} f(n) = \int_{1}^{x} f(t) dt + \int_{1}^{x} (t- [t]) f^{'}(t)dt+f(x)([x]-x)$$
\end{cor}

\begin{proof}
It is obvious when $y=1$ the term $[y]-y$ will vanish from the Euler Summation formula.
\end{proof}



\chapter{Applications of Euler Summation Formula}

Before applying the Euler summation formula for finding the arithmetical functions in terms of well know functions we Euler constant and the Riemann Zeta function.

\begin{definition}
\textbf{Euler Constant} We define the Euler constant $C$ defined by the following equation
$$ C = \lim_{n \rightarrow \infty} \left( 1 + \frac{1}{2} + \frac{1}{3} + \ldots + \frac{1}{n} - \log n \right)$$
\end{definition}

\begin{definition}
\textbf{Riemann Zeta Function} The Reimann Zeta function $\xi(s)$ is defined as
$$\xi(s) = \sum_{n=1}^{\infty} \frac{1}{n^s} \hspace{.8 cm}  s >1$$
$$ \xi(s) = \lim_{x \rightarrow \infty} \left( \sum_{n \leq x} \frac{1}{n^s} - \frac{x^{1-s}}{1-s} \right) \hspace{ .5 cm} 0 < s<1$$
\end{definition}

\begin{theorem}
If $x \geq 1$ we have
\begin{enumerate}
  \item $\sum_{n\leq x} \frac{1}{n} = \log x +C+ O\left( \frac{1}{x} \right)$
  \item $\sum_{n\leq x} \frac{1}{n^s}= \frac{x^{1-s}}{1-s}+\xi(s)+O(x^{-s})$ if $s > 0$
  \item $\sum_{n > x} \frac{1}{n^s} = O(x^{1-s})$ if $s >1 $
\end{enumerate}
\end{theorem}

\begin{proof}
\textbf{1} We apply the Euler summation formula for the function $f(t)-\frac{1}{t}$ for the sum $\sum_{n \leq x}$
$$ \sum_{n\leq x} \frac{1}{n}= \int_{1}^{x} \frac{dt}{t} - \int_{1}^{x} \frac{t- [t]}{t^2} dt - \frac{x-[x]}{x}+ f(1)$$
$$ = \log x - \int_{1}^{x} \frac{t- [t]}{t^2} dt + O\left( \frac{1}{x} \right) +1$$
$$ = \log x +1- \int_{1}^{\infty} \frac{t- [t]}{t^2} dt + \int_{x}^{\infty} \frac{t- [t]}{t^2} dt +O\left( \frac{1}{x} \right)$$
The improper integral $\int_{1}^{\infty} \frac{t- [t]}{t^2} dt$ exists since it is dominated by $ \int_{1}^{\infty} \frac{1}{t^2} dt$. Also
$$ 0 \leq \int_{x}^{\infty} \frac{t-[t]}{t^2} dt \leq \int_{x}^{\infty} \frac{1}{t^2} dt = \frac{1}{x}$$
So the equation become
$$\sum_{n \leq x} \frac{1}{n} = \log x +1 - \int_{1}^{\infty} \frac{t- [t]}{t^2} dt + O\left( \frac{1}{x} \right)$$
This proves the first with $ C = 1 - \int_{1}^{\infty} \frac{t- [t]}{t^2} dt$ because
$$C= \lim_{x \rightarrow \infty} \left( \sum_{n \leq x} \frac{1}{n} - \log x \right) = 1 - \int_{1}^{\infty} \frac{t- [t]}{t^2} dt$$

\textbf{2} \hspace{ .3 cm} For the second part we apply the Euler summation formula for the function $f(t)= t^{-s}$ where $s > 0$
$$ \sum_{n \leq x} \frac{1}{n^s} = \int_{1}^{x}\frac{dt}{t^s} -s \int_{1}^{x} \frac{t-[t]}{t^{s+1}} dt - \frac{x - [x]}{x^s} + 1 $$
$$ = \frac{x^{1-s}}{1-s} - \frac{1} { 1-s} +1 -s \int_{1}^{\infty} \frac{t - [t]}{t^{s+1}} dt + O(x^{-s}) $$
Therefore
$$ \sum_{n \leq x} \frac{1}{n^s} = \frac{x^{1-s}}{1-s}+C(s) + O(x^{-s})$$
where
$$C(s) = 1 - \frac{1}{1-s} -s \int_{1}^{\infty} \frac{t-[t]}{t^{s+1}} dt $$
If $s >1 $ the left hand side of the previous equation will approach to $\xi(s)$ as the terms $ x^{1-s}$ and $x^{-s}$ both approaches to $0$. Hence $C(s) = \xi(s)$.\\
If $ 0 < s<1$ $x^{-s} \rightarrow 0$ and the equation becomes
$$ \lim_{x \rightarrow \infty} \left(\sum_{n \leq x} \frac{1}{n^s} - \frac{x^{1-s}}{1-s} \right) = C(s)$$
Therefore we have proved the second part as well.\\

\textbf{3} \hspace{ .3 cm} For the third part, we will use the second part  with $s >1$ to obtain
$$ \sum_{n >x} \frac{1}{n^{s}} = \xi(s) - \sum_{n \leq x} \frac{1}{n^s} = \frac{x^{1-s}}{s-1} + O(x^{-s})=O(x^{1-s})$$
since $x^{-s} \leq x ^{1-s} $.
\end{proof}


\chapter{Average order of divisor and Euler function}

We need one more result in continuation of the previous results about the sum of harmonic  type terms.

\begin{theorem}
If $x \geq 1$
$$\sum_{n \leq x}= \frac{x^{\alpha+1}}{\alpha+1} + O(x^{\alpha})$$
for $\alpha \geq 0$.
\end{theorem}

\begin{proof}
Apply the Euler summation formula for the function $f(t)=t^{\alpha}$ to obtain

$$\sum_{n \leq x} = \int_{1}^{x} t^{\alpha} dt + \alpha \int_{1}^{x} t^{\alpha -1} (t - [t]) dt+1 - (x-[x]) x^{\alpha}$$
$$= \frac{x^{\alpha+1}}{\alpha +1} - \frac{1}{\alpha+1} + O \left( \alpha \int_{1}^{x} t^{\alpha -1} dt \right) + O(x^{\alpha})$$
$$=\frac{\alpha+1}{\alpha+1} + O(x^{\alpha +1})$$

\end{proof}

\section{Average order of divisor function}

\begin{theorem}
$\sum_{n \leq x} d(n) = x \log x +O(x)$
\end{theorem}

\begin{proof}
$$\sum_{n \leq x } d(n) = \sum_{n \leq x} \sum_{d \mid n} 1$$
$$= \sum_{q,d \leq x } 1 $$ 
$$= \sum{d \leq x} \sum_{q \leq \frac{x}{d}} 1 $$
Now we apply the previous theorem for $\alpha=0$ which will be of the form

$$ =\sum_{n \leq \frac{x}{d}} n^{0}= \frac{x}{d} +O(1)$$
$$= x \sum_{d \leq x} \frac{1}{d} +O(1)$$
$$= x \{ \log x +C + O\left( \frac{1}{x} \right) \} +O(x)$$
$$= x \log x +O(x)$$
\end{proof}

\section{Average order of Euler $\phi$ function}

Before finding the average order of $\phi $ function we will prove an identity which we will use in the proof of average order.

\begin{theorem}
$$\sum_{\mu(n)}{n^2} = \frac{6}{\pi^2}$$
\end{theorem}

\begin{proof}
We know that $I(n)=0$ for all $n > 1$, so we can write
$$ 1 = \sum_{n=1}{\infty} \frac{I(n)}{n^2} $$
Now we apply the identity $ I(n) = \sum_{d \mid n} \mu(d) $ and get
$$1= \sum_{n=1}^{\infty} \frac{\sum_{d \mid n} \mu(d)}{n^2} = \sum_{d=1}^{\infty} \sum_{m=1}{\infty} \frac{\mu(d)}{(dm)^2}$$
$$ 1= \sum_{d=1}^{\infty} \frac{\mu(d)}{d^2} \sum_{m=1}^{\infty} \frac{1}{m^2}$$
$$ \sum_{d=1}^{\infty} \frac{\mu(d)}{d^2} = \left( \sum_{m=1}^{\infty} \frac{1}{m^2} \right)^{-1}=\left( \frac{\pi^2}{6} \right)^{-1}$$
$$\sum_{d=1}^{\infty} \frac{\mu(d)}{d^2} = \left( \frac{6}{\pi^2} \right)$$
\end{proof}


\begin{theorem}
$$ \sum_{n \leq x} \phi(n) = \frac{3 x^2}{\pi^2} +O(x \log x) $$
\end{theorem}

\begin{proof}
$$\sum_{n \leq x} \phi(n) = \sum_{n \leq x} {d \mid n} \mu(d) \frac{n}{d}$$
$$= \sum_{q,d \leq x} \mu(d) q $$
$$ = \sum_{d \leq x} \sum_{q \leq {x}{d}} \mu(d) q$$
$$ = \sum_{d \leq x} \mu(d) \sum_{q \leq frac{x}{d}} q$$
Now using the previous results for harmonic type functions we have

$$ =\sum_{d \leq x} \mu(d) \left\{\frac{1}{2} \left(\frac{s}{d} \right)^2+O \left( \frac{x}{d} \right) \right\}$$
$$=\frac{x^2}{2} \sum_{d \leq x} \frac{\mu(d)}{d^2} + O\left( x \sum_{d \leq x} \frac{1}{d} \right)$$
Now using the previous identity which we proved we have the following
$$= \frac{3x^6}{\pi^2} +O(x \log x)$$%%
\end{proof}


% 1 z q a Q A Z


\cleardoublepage
\phantomsection
\pdfbookmark[0]{Index}{Index}
\printindex
\end{document}
