\documentclass[12pt]{article}   
\usepackage{latex-macros/course}% !! use the macros

%\showsolutions	 		% !! use to force solutions & skip query
%\hidesolutions			% !! use to force no solutions & skip query

\newcommand{\mfigure}[3]{\bigskip\centerline{\resizebox{#1}{#2}{\includegraphics{#3}}}\bigskip}

\instatements{
\renewcommand{\exampreamble}{	% !! renew \exampreamble 
  \textbf{Circle the name of your Tutorial Instructor}:
  \begin{center}
  \renewcommand{\arraystretch}{1.5}
  \begin{tabular}{lllll}
Ching & Christos & Grant & Paul & Zardosht
  \end{tabular}
  \end{center}
  \begin{itemize}
  \item 
  This quiz is \textbf{closed book}, but you may have one sheet of paper with
  notes on both sides.
  \item 
  There are ???? problems totaling ??? points. Total time is 80 minutes. 
  \item 
  Write your solutions in the space provided.  If you need more
  space, write on the back of the sheet containing the problem.
  Please keep your entire answer to a problem on that problem's page.
  \item 
  You may assume all of the results presented in class and in the
  assigned reading.
  \item  
  \textbf{Be neat and write legibly}.  You will be graded not only on
  the correctness of your answer, but also on the clarity with which
  you express it.
  \item 
  GOOD LUCK!
  \end{itemize}}}

\begin{document} 
\quiz{2}			% !! start the paper

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{examproblem}{15}
Sammy the Shark is a financial service provider who offers loans on
the following terms.

\begin{enumerate}

\item Sammy loans a client $m$ dollars in the morning.  This puts the
client $m$ dollars in debt to Sammy.

\item Each evening, Sammy first charges a ``service fee'', which
increases the client's debt by $f$ dollars, and then Sammy charges
interest, which multiplies the debt by a factor of $p$.  Thus, if
Sammy's interest rate is a reasonable 25\% per day, then $p = 1.25$.

\end{enumerate}

\bparts

\ppart[5] What is the client's debt at the end of the first day?

\solution[\vspace{1in}]{At the end of the first day, the client owes
Sammy $(m + f) p = m p + f p$ dollars.}

\ppart[5] What is the client's debt after $d$ days?  Your answer need
not be a closed-form expression.

\solution[\vspace{2in}]{The client owes

\begin{eqnarray*}
((m + f) p + f) p & = & m p^2 + f p^2 + f p
\end{eqnarray*}

after two days, and owes

\begin{eqnarray*}
(((m + f) p + f) p + f) p & = & m p^3 + f p^3 + f p^2 + f p
\end{eqnarray*}

after three days.  Generalizing from this pattern, the client owes

\[
m p^d + f \cdot \sum_{k=1}^d p^k
\]

dollars after $d$ days.}

\ppart[5] Give a closed-form expression for the client's debt after
$d$ days.

\solution[\vspace{2in}]{Applying the formula for the sum of a
geometric series to the preceding expression gives:

\begin{eqnarray*}
m p^d + f \cdot \left(\frac{p^{d+1} - 1}{p - 1} - 1 \right)
\end{eqnarray*}
}

\eparts

\end{examproblem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{examproblem}{15}
Let $p$ be a prime greater than 2, and let $x$ be an integer.  A {\em
square root of $x$ modulo $p$} is an integer $r$ such that:

\begin{eqnarray*}
r^2 \equiv x \pmod{p}
\end{eqnarray*}

\bparts

\ppart[5] List every square root of 4 modulo 7 in the set $\set{0, 1,
\ldots, 6}$.

\solution[\vspace{1.5in}]{2 and 5}

\ppart[10] Let $s$ be one square root of $x$ modulo $p$.  Show $r$ is
a square root of $x$ modulo $p$ if and only if:

\[
r \equiv s \pmod{p}
\hspace{0.5in} \text{or else} \hspace{0.5in} r \equiv - s \pmod{p}
\]

Hint: $p \mid (s - r) (s + r)$

\solution[\newpage]{Since $s^2 \equiv x \pmod{p}$ and $r^2 \equiv x
\pmod{p}$, we know that $s^2 \equiv r^2 \pmod{p}$.  This means that $p
\mid (s^2 - r^2)$, which is equivalent to $p \mid (s - r) (s + r)$.
Since $p$ is a prime, this holds if and only if either $p \mid s - r$
(which means $r \equiv s \pmod{p}$) or else $p \mid s + r$ (which
means $r \equiv - s \pmod{p}$).}

\eparts

\end{examproblem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{examproblem}{10}
We have a deck with 54 cards.  (We left the two jokers in.)  In a {\em
perfect shuffle}, we cut the deck exactly in half and then interlace
the two halves.  The top card remains on the top after the shuffle,
and the bottom card remains on the bottom.  A perfect shuffle with an
8-card deck is illustrated below:

\bigskip
\centerline{\resizebox{5in}{!}{\includegraphics{perfectshuffle}}}
\bigskip

Suppose there are initially $i$ cards above card $C$.  Then number of
cards above $C$ after a perfect shuffle is congruent to $2i$ modulo
53.  You may assume this without proof, though it is not difficult to
verify.

\bparts

\ppart[4] Suppose there are initially $i$ cards above card $C$.  The
number of cards above $C$ after $k$ perfect shuffles must be congruent
to

\bigskip
\centerline{\fbox{\begin{minipage}{1.5in}
\instatements{\hspace{1.5in}\vspace{0.75in}}
\insolutions{\bigskip \centerline{$2^k \cdot i$} \bigskip}
\end{minipage}} \quad modulo 53.} 

\ppart[6] Prove that 52 successive perfect shuffles restore the deck
to its original configuration.  (Continue your argument on the back
side of this page if necessary.)

\solution{The top and bottom cards never move.  Consider a card $C$
with $i \in \set{1, 2, \ldots, 52}$ cards above.  After 52 perfect
shuffles:

\begin{eqnarray*}
\text{\# of cards above $C$}
    & \equiv & 2^{52} \cdot i \pmod{53} \\
    & \equiv & 1 \cdot i \pmod{53} \\
    & \equiv & i \pmod{53}
\end{eqnarray*}

The second congruence uses Fermat's Theorem, which implies that
$2^{52} \equiv 1 \pmod{53}$.  If the number of cards above $C$ is
congruent to $i \in \set{1, 2, \ldots, 52}$, then it must be equal to
$i$.  Thus, every card returns to its original position and the deck
is restored after 52 perfect shuffles.}

\eparts

\end{examproblem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}
