142 lines
4.3 KiB
TeX
Executable File
142 lines
4.3 KiB
TeX
Executable File
\section{Challenge Problems}
|
|
|
|
|
|
\problem{}
|
|
Prove \ref{mod_has_inverse}: \\
|
|
$a$ has an inverse mod $m$ iff $\gcd(a, m) = 1$ \\
|
|
\begin{hint}
|
|
To prove an iff statement, prove each direction separately: \\
|
|
Assume that the left side is true and show that left $\implies$ right, \\
|
|
then do the reverse.
|
|
\end{hint}
|
|
|
|
|
|
\begin{solution}
|
|
Assume $a^\star$ is the inverse of $a \pmod{m}$. \\
|
|
Then $a^\star \times a \equiv 1 \pmod{m}$ \\
|
|
|
|
Therefore, $aa^\star - 1 = km$, and $aa^\star - km = 1$ \\
|
|
We know that $\gcd(a, m)$ divides $a$ and $m$, therefore $\gcd(a, m)$ must divide $1$. \\
|
|
$\gcd(a, m) = 1$ \\
|
|
|
|
Now, assume $\gcd(a, m) = 1$. \\
|
|
By the Extended Euclidean Algorithm, we can find $(u, v)$ that satisfy $au+mv=1$ \\
|
|
So, $au-1 = mv$. \\
|
|
$m$ divides $au-1$, so $au \equiv 1 \pmod{m}$ \\
|
|
$u$ is $a^\star$.
|
|
\end{solution}
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
\problem{}<eua_runtime>
|
|
The Euclidean Algorithm (From \ref{euclid_algorithm}) can be written as follows: \\
|
|
|
|
Assume $a > b$.
|
|
Set $e_0 = a$ and $e_1 = b$. \\
|
|
Let $e_{n+1} = \text{remainder}(r_{n-1} \div r_{n})$ \\
|
|
Stop when $e_{k} = 0$.
|
|
Then, $\gcd(a, b) = e_{k-1}$. \\
|
|
|
|
Let $F_n$ be the $n^{\text{th}}$ Fibonacci number. ($F_0 = 0$; $F_1 = 1$; $F_2 = 1$; $\dots$)\\
|
|
Show that if the Euclidean algorithm requires $n$ steps for an input $(a, b)$, then $a \geq F_{n+2}$ and $b \geq F_{n+1}$.
|
|
|
|
(In other words, show that the longest-running input of a given size is a Fibonacci pair.)
|
|
|
|
\begin{solution}
|
|
The easiest way to go about this is induction on $n$: \\
|
|
|
|
\textcolor{gray}{\textit{Base Case:}}
|
|
|
|
If $n = 1$, $b$ divides $a$ with no remainder, and the smallest possible $a, b$ for which this is true is $(2, 1) = (F_3, F_2)$.
|
|
|
|
\linehack{}
|
|
|
|
\textcolor{gray}{\textit{Induction:}}
|
|
|
|
Assume that for $n$ steps, $a \geq F_{n+2}$ and $b \geq F_{n+1}$.
|
|
|
|
Now, say the algorithm takes $n+1 = m$ steps. \\
|
|
|
|
The first step gives us $a = q_0b + r_0$ \\
|
|
Therefore, the pair $(b, r_0)$ must take $m-1$ steps. \\
|
|
We thus know that $b \geq F_{m+1}$ and $r_0 \geq F_m$ \hfill \textcolor{gray}{by our induction hypothesis} \\
|
|
Therefore, $a = q_0b + r_0 \geq b + r_0$ \\
|
|
But $b + r_0 = F_{m+1} + F_{m} = F_{m+2}$, \\
|
|
so $a \geq F_{m+2}$.
|
|
\end{solution}
|
|
|
|
\vfill
|
|
\pagebreak
|
|
|
|
\problem{Chinese Remainder Theorem}
|
|
There are certain things whose number is unknown. If we count them by threes, we have two left over; by fives, we have three left over; and by sevens, two are left over. How many things are there?
|
|
|
|
\begin{solution}
|
|
$x \equiv 2 \pmod{3}$ \\
|
|
$x \equiv 3 \pmod{5}$ \\
|
|
$x \equiv 2 \pmod{7}$ \\
|
|
|
|
$x = 23 + 105k\ \forall k \in \mathbb{Z}$
|
|
\end{solution}
|
|
|
|
\vfill
|
|
|
|
\problem{}<flt_prereq>
|
|
Show that if $p$ is prime, $\binom{p}{i} \equiv 0 \pmod{p}$
|
|
for $0 < i < p$.
|
|
|
|
\begin{solution}
|
|
$\binom{p}{i} = \frac{p!}{i!(p-i)!}$ tells us that $i!(p-i)!$ divides $p! = p(p-1)!$. \\
|
|
However, $i!(p-i)!$ and $p$ are coprime, since all factors of $i!(p-i)!$ are smaller than $p$. \\
|
|
Therefore, $i!(p-i)!$ must divide $(p-1)!$ \\
|
|
|
|
So, $\binom{p}{i} = p \times \frac{(p-1)!}{i!(p-i)!}$, and $\binom{p}{i} \equiv 0 \pmod{p}$.
|
|
\end{solution}
|
|
|
|
\vfill
|
|
|
|
\problem{Fermat's Little Theorem}
|
|
Show that if $p$ is prime and $a \not\equiv 0 \pmod{p}$, then $a^{p-1} \equiv 1 \pmod{p}$. \\
|
|
You may want to use \ref{flt_prereq}.
|
|
|
|
\begin{hint}
|
|
It may be easier to show that $a^p \equiv a \pmod{p}$
|
|
\end{hint}
|
|
|
|
|
|
\begin{solution}
|
|
Use induction:
|
|
|
|
$1 \equiv 1 \pmod{p}$ \\
|
|
|
|
Using \ref{flt_prereq} and the binomial theorem, we have
|
|
|
|
$2^p = (1 + 1)^p = 1 + \binom{p}{1} + \binom{p}{2} + \dots + \binom{p}{p-1} + 1 \equiv 1 + 0 + ... + 0 + 1 \equiv 2 \pmod{p}$ \\
|
|
|
|
Then,
|
|
|
|
$3^p = (1 + 2)^p = 1 + \binom{p}{1}2 + \binom{p}{2}2^2 + \dots + \binom{p}{p-1}2^{p-1} + 2^p \equiv 1 + 0 + ... + 0 + 2 \equiv 3 \pmod{p}$ \\
|
|
|
|
We can repeat this for all $a$. This proof can be presented more formally with a bit of induction.
|
|
|
|
\end{solution}
|
|
|
|
\vfill
|
|
|
|
|
|
%\problem{}
|
|
%Prove \ref{theorem:gcd_abc}: \\
|
|
%For any integers $a, b, c$, \\
|
|
%$\gcd(ac + b, a) = \gcd(a, b)$\\
|
|
|
|
%\begin{solution}
|
|
% This problem is hard, \\
|
|
% I'll write a solution eventually.
|
|
%\end{solution}
|
|
|
|
%\vfill
|
|
|
|
[Note on \ref{eua_runtime}] This proof can be used to show that the Euclidean algorithm finishes in logarithmic time, and it is the first practical application of the Fibonacci numbers. If you have finished all challenge problems, finish the proof: show that the Euclidean runs in $O(\log{n})$
|
|
\pagebreak |