\chapter{Unique Factorization}

A number is a way of identifying what is \textit{common} between different collections of objects. For example, 3 sheep, 3 coins, and 3 apples are all sets of 3 objects. The number 3 is a way of identifying the size of these sets. What is common is that \textit{3 of anything} can be put in correspondence with each other.

\section{Introduction}

\subsection{Notations}

\begin{definition}
    A set \( S \) is has a \term{size} \( |S| \).
\end{definition}

\begin{remark}
    If \( S = \{ a, b, c \} \) and \( T = \{ 1, 2, 3 \} \), then \( |S| = |T| = 3 \).
\end{remark}

\subsubsection{Some Operations on Sets}

% Here we ignore the fact that some objects may be in both sets. \textbf{Only the size of the sets are considered.}

Note that we are only considering the \textit{size} of the sets, not the objects themselves. We are only considering sets that are \textit{finite}.

\begin{itemize}
    \item The \term{union}\index{Set!Union} of disjoint sets \( S \) and \( T \), \( S \cup T \), is the arbitrary collection of objects in either \( S \) or \( T \). \[
              | S \cup T | = |S| + |T|
          \]

    \item For \( T \subseteq S \), the \term{difference}\index{Set!Difference} of \( S \) and \( T \), \( S \setminus T \), is removing \( T \) from \( S \), \[
              | S \setminus T | = |S| - |T|
          \]

    \item The \term{product} of two sets \( S \) and \( T \)\index{Set!Product}\footnote{\( S \times T = \left\{ (s, t), s \in S, t \in T \right\} \)}, \( S \times T \), is the set of all pairs of objects where the first object is in \( S \) and the second object is in \( T \). \[
              | S \times T | = |S| \cdot |T|
          \]
\end{itemize}

\subsection{National Numbers}

\begin{definition}\index{National Number}
    \term{National numbers} are a way of identifying the size of a set. The set of all natural numbers is denoted by \( \N \).
\end{definition}

\begin{remark}[Notation]
    To disambiguate between whether 0 is included in the set of natural numbers, we use
    \begin{itemize}
        \item \( \N_{\geq 0} \) to include 0,
        \item \( \N_{> 0} \) to exclude 0.
    \end{itemize}
\end{remark}

\begin{remark}[Observation]
    Every \( |S| \) appears somewhere in this list. Size gets \textbf{smaller} as you remove things.
\end{remark}

\begin{axiom}[Peano Axioms (for \( \N_{\geq 0} \))]\index{Peano Axioms}

    \begin{enumerate}[label=(\Roman*)]
        \item There exists an element \( 0 \).
        \item For each \( n \in \N_{\geq 0} \), there exists \( S(n) \in \N_{\geq 0} \) such that \( S(n) = S(m) \implies n = m \). \( S \) is an operator called the \term{successor} operator.
        \item \textbf{Induction Schema} For any property \( P \)  on \( N \), if
              \begin{itemize}
                  \item \( P(0) \) is true, and
                  \item \( P(n) \implies P(S(n)) \)
              \end{itemize}
              Then \( P(n) \) is true for all \( n \in \N_{\geq 0} \).
    \end{enumerate}
\end{axiom}

\begin{example}[System Where III Fails]
    Take \( \Z \in \N_{\geq 0} \cup -\N_{\geq 0} \), the set of all integers. \( S(n) = n + 1 \).
\end{example}

\section{Prime and Irreducible Numbers}

\subsection{Multiplication and Division}

\begin{definition}[Divisibility]\index{Divisibility}
    \( n \) divides \( m \) if there exists \( u \) such that \( m = nu \). We write \( a \mid b \).
\end{definition}

\begin{definition}[Prime Number (Definition I - Irreducible Number)]\index{Prime Number}\index{Irreducible Number}
    A number \( p \neq 1 \) is \term{irreducible} if \( p \) is not 1 and the only divisors of \( p \) are 1 and \( p \). In other words, \[
        p = uv \implies u = 1 \text{ or } v = 1.
    \]
\end{definition}

\begin{definition}[Prime Number (Definition II - Prime Number)]\index{Prime Number}
    A number \( p \) is \term{prime} if \( \forall a, b \) such that \( p \mid ab \), \( p \mid a \) or \( p \mid b \).
\end{definition}

\begin{theorem}
    If \( p \) is prime, then \( p \) is irreducible.
\end{theorem}

\begin{proof}
    WTS \( n \) is reducible \( \implies n \) is not prime.

    Assume \( n \) is reducible, \( n = ab \) with \( a, b \neq 1 \).

    Then, \( n \mid ab \), but \( n \nmid a \) and \( n \nmid b \) as \( n > a, b \).
\end{proof}

\begin{note}[System Where Irreducible $\not\implies$ Prime]
    In this system, the Bezout's Identity does not hold.

        {~~~}

    Take \( \Z \left[ \sqrt{-5} \right] = \{ a + b\sqrt{-5}, {~~~} a, b \in \Z \} \)

    Let \( a = 1 + \sqrt{-5} \), \( b = 1 - \sqrt{-5} \).

    \begin{align*}
        a + b & = 3 + 2 \sqrt{5}                 \\
        a b   & = (1 + \sqrt{-5})(1 - \sqrt{-5}) \\
              & = 1 - \sqrt{-5} + \sqrt{-5} + 5  \\
              & = 6
    \end{align*}

    Now consider the number $6$. \[
        6 = 2 \cdot 3 = (1 + \sqrt{-5})(1 - \sqrt{-5})
    \]

    Turns out \( 2, 3, 1 \pm \sqrt{-5} \) are all irreducible but not prime.

    For example, $2 \mid (1 + \sqrt{-5})(1 - \sqrt{-5})$ but $2 \nmid 1 \pm \sqrt{-5}$.
\end{note}

\subsection{GCD and Bezout's Identity}

\begin{definition}[Greatest Common Divisor]\index{Greatest Common Divisor}
    The \term{greatest common divisor} of \( a \) and \( b \) is the largest number that divides both \( a \) and \( b \).

    \( d = gcd(a, b) \) if \( d \mid a \), \( d \mid b \), and for any \( c \) such that \( c \mid a, b \), we have \( c \mid d \).
\end{definition}

\begin{remark}
    Note that if we change the definition to \( c \leq d \), it is clear that $gcd$ exists. However, with the given definition, we need to prove that $gcd$ exists, as we may land in the case where \( c < d \) but \( c \nmid d \).
\end{remark}

\begin{theorem}\label{thm:gcd-exists}
    For any \( a, b \in \N_{> 0} \), \( gcd(a, b) \) exists.
\end{theorem}

\begin{remark}
    \begin{minipage}[t]{0.45\linewidth}
        Consider \( a = 30 \) and \( b = 12 \).

        \begin{center}
            \begin{tikzpicture}[
                    every node/.style = {draw, circle, minimum size = 0.75cm},
                ]
                \node (1) at (1, 0) {\( 1 \)};
                \node (2) at (0, 1) {\( 2 \)};
                \node (3) at (2, 1) {\( 3 \)};
                \node (6) at (1, 2) {\( 6 \)};

                \draw (1) -- (2);
                \draw (1) -- (3);
                \draw (2) -- (6);
                \draw (3) -- (6);
            \end{tikzpicture}
        \end{center}
    \end{minipage}
    \begin{minipage}[t]{0.45\linewidth}
        Consider \( a = 60 \) and \( b = 15 \).

        \begin{center}
            \begin{tikzpicture}[
                    every node/.style = {draw, circle, minimum size = 0.75cm},
                ]
                \node (1) at (1, 0) {\( 1 \)};
                \node (3) at (0, 1) {\( 3 \)};
                \node (5) at (2, 1) {\( 5 \)};
                \node (15) at (1, 2) {\( 15 \)};

                \draw (1) -- (3);
                \draw (1) -- (5);
                \draw (3) -- (15);
                \draw (5) -- (15);
            \end{tikzpicture}
        \end{center}
    \end{minipage}
\end{remark}

\begin{lemma}[Bezout's Identity]\index{Bezout's Identity}
    For any \( a, b \in \N_{> 0} \), there exist \( x, y \in \Z \) such that \( ax + by = gcd(a, b) \).
\end{lemma}

\begin{example}
    Consider $a = 7$ and $b = 9$, $gcd(7, 9) = 1$.

    We have $7 \cdot 5 + 9 \cdot (-4) = 1$.
\end{example}

Define \[ S = \{ ax + by \mid x, y \in \Z, ax + by > 0 \}. \]

\begin{lemma}
    \( gcd \) is the smallest (positive) element of \( S \).
\end{lemma}

\begin{proof}
    WTS \( gcd(a, b) = d \iff d \mid a, b \) and \( d \) for any \( c \mid a, b \), we have \( c \mid d \).

    Let $m$ be the smallest element of $S$. $m = ax + by$ for some $x, y \in \Z$.

    \begin{enumerate}
        \item WTS \( m \mid a, b \)

              Let \( a = km + r \) where \( 0 \leq r < m \).

              Then, \( r = a - km = a(1 - kx) + b(ky) \) is in \( S \cup \{ 0 \} \), but \( m \) is the smallest element in \( S \) so \( r < m \).

              Therefore, \( r = 0 \), \( a = km \), and $m \mid a$.

              The same argument can be applied to \( b \).

        \item WTS for any \( c \mid a, b \), we have \( c \mid m \)

              Let \( c \mid a, b \).

              Then, \( a = cu \) and \( b = cv \) for some \( u, v \in \Z \).

              Then, \( m = ax + by = cux + cvy = c(ux + vy) \).

              Therefore, \( c \mid m \).
    \end{enumerate}

    Thus, the smallest element of \( S \) is \( gcd(a, b) \).
\end{proof}

\begin{theorem}
    If \( p \) is irreducible, then \( p \) is prime.
\end{theorem}

\begin{proof}
    Let \( p \) be irreducible.

    Suppose \( p | ab \). That is, \( pu = ab \) for some \( u \).

    WTS \( p | a \) or \( p | b \).

    Assume \( p \nmid a \). Then, \( gcd(p, a) = 1 \) since \( p \) irreducible.

    By Bezout's Identity, \( 1 = px + ay \) for some \( x, y \in \Z \).

    Consider \( d = gcd(p, b) \).

    Then, \( b = b(px + ay) = pbx + aby = pbx + puy = p(bx + uy) \).

    In other words, \( p | b \).
\end{proof}

\section{Unique Factorization}

\begin{definition}[Factorization]\index{Factorization}
    A \term{factorization} of \( a \) is a representation of \( a \) as a product of irreducible numbers.
\end{definition}

\begin{definition}[Prime (More General)]\index{Prime Number}
    A number \( p \) is \term{prime} if \( p \neq 1 \) and \( p \mid a_1 a_2 \cdots a_k \) implies \( p \mid a_i \) for some \( i \).
\end{definition}

\begin{theorem}
    \( \N \) has unique factorization.

    That is, if \( a = p_1 p_2 \cdots p_k = p_k = q_1 q_2 \cdots q_l \) with \( p_i, q_j \) irreducible., then \( k = l \) and \( p_i \) and \( q_j \) are the same up to reordering.
\end{theorem}

% \begin{proof}
%     WTS \( k = l \) and \( p_i = q_j \) up to reordering.

%     We will prove this by induction on \( a \).

%     \begin{enumerate}
%         \item Base Case: \( a = 1 \)

%               \( 1 = 1 \) is the only factorization.

%         \item Inductive Step: Assume true for all \( b < a \).

%               Let \( a = p_1 p_2 \cdot p_k = q_1 q_2 \cdot q_l \).

%               WTS \( k = l \) and \( p_i = q_j \) up to reordering.

%               WLOG, assume \( p_1 = q_1 \).

%               Then, \( p_2 \cdot p_3 \cdot p_k = q_2 \cdot q_3 \cdot q_l \).

%               By induction, \( k - 1 = l - 1 \) and \( p_2 \cdot p_3 \cdot p_k = q_2 \cdot q_3 \cdot q_l \).

%               Therefore, \( k = l \) and \( p_i = q_j \) up to reordering.
%     \end{enumerate}
% \end{proof}

\begin{proof}
    Since \( p_1 \) irreducible, \( p_1 \) is prime.

    Therefore, \( p_1 | q_1 q_2 \cdots q_l \) implies \( p_1 | q_i \) for some \( i \).

    Say \( p_1 | q_1 \).

    Then, \( q_1 = p_1 u \) for some \( u \).

    Say \( p_1 = q_1 \).

    Then, \( p_2 \cdots p_k = q_2 \cdots q_l \).

    By induction, \( k = l \) and \( p_i = q_j \) up to reordering.

    Therefore, \( \N \) has unique factorization.
\end{proof}

\begin{remark}
    Up to \( N \), how many prime numbers are there? \[
        \frac{N}{\log N} + \mathcal{O}\left( N^{1/2} \right)
    \]
    where the \( \mathcal{O} \) term is the Riemann Hypothesis.
\end{remark}

\section{Distribution of Primes}

Are there infinitely many primes? Yes! Euclid proved this 2000 years ago.

\subsection{Euclid's Algorithm}

How to show that there are infinitely many primes? Given a list of primes \[
    S = \{ p_1, p_2, \dots, p_k \},
\]we can construct a new prime \( p \notin S \).

\begin{example}
    Consider \( S = \{ 2, 3, 5 \} \).

    We suggest \( N = 2 \times 3 \times 5 + 1 = 31 \).

    We know that \( 31 \) is not divisible by \( 2, 3, 5 \), but it has a prime factorization, \( 31 = 1 \times 31 \).

    Thus, there must be some prime \( p = 31 \) that is not in \( S \).
\end{example}

\begin{theorem}
    There are infinitely many primes.
\end{theorem}

\begin{proof}[Proof (Euclid's Algorithm)]
    Let \( S = \{ p_1, p_2, \dots, p_k \} \) be a list of primes.

    Consider \( N = \left( p_1 \cdot p_2 \cdots p_k \right) + 1 \).

    \( N \) has a remainder of \( 1 \) when divided by any of the primes in \( S \), so it must have a prime factor distinct from the primes in \( S \).
\end{proof}

\begin{remark}
    The proof is constructive, but it does not give us a way to find the next prime.
\end{remark}

\subsection{Prime Number Theorem}

How many primes are there up to \( N \)? Denote this as \( \Pi(N) \). As \( N \to \infty \), what is the behavior of \( \Pi(N) \)?

\subsubsection{Method of Inclusion-Exclusion}

\begin{remark}
    An obvious statement would be \( \Pi(N) \leq N \).
\end{remark}

\begin{itemize}
    \item \textbf{Divisible by 2:} \( \Pi(x) \leq \frac{1}{2} (x-2) + 1 \) because half of the numbers are even.

          The \( x - 2 \) comes from excluding 1 and 2, while \( +1 \) is for 2.

    \item \textbf{Divisible by 3:} \( \Pi(x) \leq \frac{2}{3} (x-3) + 1 \) is a better bound.
\end{itemize}

We observe that the divisible by \( 2 \) case is a closer bound \( \sim \frac{x}{2} \). However, we know that numbers divisible by both \( 2 \) and \( 3 \) are also not primes. Using inclusion-exclusion, we can get a better bound \[
    \Pi(x) \leq \text{divisible by 2} + \text{divisible by 3} - \text{divisible by 6}.
\] This idea is known as the \term{Sieve of Eratosthenes}.

\begin{remark}[Sieve of Eratosthenes]\index{Sieve of Eratosthenes}
    The Sieve of Eratosthenes is a way to find all primes up to a certain number.

    \begin{enumerate}
        \item Write down all numbers from 2 to \( N \).
        \item Circle 2 and cross out all multiples of 2.
        \item Circle the next number that is not crossed out and cross out all multiples of that number.
        \item Repeat until all numbers are either circled or crossed out.
    \end{enumerate}
\end{remark}

Thus, we have the bound \[
    \Pi(x) \leq x \left( 1 - \frac{1}{2} \right) \left( 1 - \frac{1}{3} \right) \left( 1 - \frac{1}{5} \right) \cdots
\]

\begin{remark}
    Note that \[
        x \left( 1 - \frac{1}{2} \right) \left( 1 - \frac{1}{3} \right) = x \left( 1 - \frac{1}{2} - \frac{1}{3} + \frac{1}{6} \right),
    \] which is precisely what we get from inclusion-exclusion.
\end{remark}

\subsubsection{Method of Prime Factorization}

Recall that any number has a unique prime factorization \[
    n = p_1^{e_1} p_2^{e_2} \cdots p_k^{e_k}
\] where \[
    p_i \leq n \qquad \text{and} \qquad e_i \leq \log_{p_i} n \leq \log_2 n.
\]

Suppose \( \left( p_1, \dots, p_k \right) \) are all the primes up to \( x \), \( k = \Pi(x) \). There will be \[
    \left( \log_2 x + 1 \right)^k
\] possible numbers up to \( x \).

\begin{remark}
    Each \( p_i \) could have power \( 0, 1, \dots, \log_2 x \). Thus, We have \( k \) choices of primes, and each prime has \( \log_2 x + 1 \) choices of powers. This gives us \( \left( \log_2 x + 1 \right)^k \) combinations.
\end{remark}

Thus, \begin{align*}
    \left( \log_2 x + 1 \right)^k & \geq x                                       \\
    k \log_2 (\log_2 x + 1)       & \geq \log_2 x                                \\
    k                             & \geq \frac{\log_2 x}{\log_2 (\log_2 x + 1)}.
\end{align*}

Since \( k = \Pi(x) \), we have \[
    \Pi(x) \geq \frac{\log_2 x}{\log_2 (\log_2 x + 1)} \approx \frac{\log_2 x}{\log_2 \log_2 x}.
\]

\begin{theorem}[Prime Number Theorem]
    \[
        \lim_{x \to \infty} \Pi(x) - \frac{x}{\ln x} = 0.
    \]
\end{theorem}

\subsection{Riemann Zeta Function}

\begin{definition}[Riemann Zeta Function]\index{Riemann Zeta Function}
    The \term{Riemann Zeta Function} is defined as \[
        \zeta(s) = \sum_{n=1}^{\infty} \frac{1}{n^s}.
    \]
\end{definition}

\begin{remark}
    For what values of \( s \) does the series converge?

    If \( s > 1 \), then the series converges.

    Recall the integral test \[
        \sum_{n=1}^{\infty} \frac{1}{n^s} \sim \int_1^{\infty} \frac{1}{x^s} \, dx
    \] in terms of convergence and divergence.

    \begin{align*}
        \int_1^\infty \frac{1}{x^s} \, dx
         & = \left. \frac{x^{1-s}}{1-s} \right|_1^\infty \\
         & = \frac{1}{s - 1}
    \end{align*} which is finite if \( 1 - s < 0 \iff s > 1 \).
\end{remark}

Why is the Riemann Zeta Function important? It is related to the distribution of primes.

Consider \[
    \prod_{p \text{ prime}} \left( \sum_{n=1}^{\infty} \frac{1}{p^{n}} \right).
\] Each term in the expansion looks like \[
    \frac{1}{2^{n_2}} 3^{n_3} 5^{n_5} \cdots
\] By Unique Factorization, each number of from \( \frac{1}{n} \) appears exactly once in the expansion, so the product is \[
    \prod_{p \text{ prime}} \left( \sum_{n=1}^{\infty} \frac{1}{p^{n}} \right) = \sum_{n=1}^{\infty} \frac{1}{n}.
\] Similarly, \[
    \prod_{p \text{ prime}} \left( \sum_{n=1}^{\infty} \frac{1}{p^{ns}} \right) = \sum_{n=1}^{\infty} \frac{1}{n^s}.
\]

\begin{proof}[Proof due to Euler]
    WTS there are infinitely many primes.

    \[
        \zeta(s) = \sum_{n=1}^{\infty} \frac{1}{1 - \left( \frac{1}{n} \right)^s} = \prod_{p \text{ prime}} \left( \frac{1}{1 - p^{-s}} \right).
    \] If there were finitely many primes, then \[
        \frac{1}{1 - p^{-1}} \neq \infty
    \] so finite product of such terms would be finite. However, we know that \( \zeta(1) \) diverges, so there must be infinitely many primes.
\end{proof}

\begin{remark}
    \[
        \zeta(2) = \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}
    \] which is irrational.

    If there were finitely many primes, then \[
        \zeta(2) = \prod_{i=1}^k \left( 1 - \frac{1}{{p_i}^2} \right)^{-1}
    \] would be rational, which is a contradiction.
\end{remark}

Alternatively, consider the harmonic series \[
    H(x) = \sum_{n=1}^{x} \frac{1}{n} \sim \ln x \sim \int_2^x \frac{1}{t} \, dt = \frac{\ln x}{\ln 2}.
\]

\begin{remark}
    \[
        H(x) \sim \prod_{p \leq x} \left( \frac{1}{1 - p^{-1}} \right).
    \]
    We can use this to bound the number of primes.
\end{remark}

Analyzing the zeta function on the complex plain is very important in bounding the number of primes. We will see this at the end of the course.

\begin{example}
    Are there infinitely many primes of the form \( 4k + 3, k \in \N \)?

    Examples include \( 3, 7, 11, 19, 23, \dots \).

    Yes.

    \begin{proof}
        Suppose there are finitely many primes of the form \( 4k + 3 \), \( p_1, p_2, \dots, p_k \).

        Consider \( N = 4 \left( \prod_{i=1}^k p_i \right) + 3 \), \( N \) coprime to all \( p_i \).

        \( N \) must have a prime factor of the form \( 4k + 3 \).

        Suppose not. Then, all prime factors of \( N \) are of the form \( 4k + 1 \).

        Consider \( 4m + 1 \) and \( 4n + 1 \).

        Then, \( (4m+1) \cdot (4n+1) = 4(4mn + m + n) + 1 \) is also of the form \( 4k + 1 \). This is a contradiction.
    \end{proof}
\end{example}