\chapter{Solutions to Exercises}   

%\begin{solutions}{ch:primes}{1}
%\item[\chap.\ref{ex:binomdiv}] This is a solution.
%\end{solutions}

\begin{solutions}{ch:primes}{1}
\item[\chap.\ref{ex:binomdiv}]
First we show by induction on~$n$ that the binomial coefficients
$\binom{n}{k}$, for $0\leq k \leq n$, are integers.
For the base case, note that $\binom{1}{0}=\binom{1}{1}=1$.
Next, suppose that $\binom{n}{k}$ is an integer for $0\leq k\leq n$.
Then $\binom{n+1}{0}=\binom{n+1}{n+1}=1$, and for $0\leq i\leq n-1$,
\begin{align*}
  \binom{n}{i} + \binom{n}{i+1} &= 
   \frac{n!}{i!(n-i-1)!}
   \left(\frac{1}{n-i} + \frac{1}{i+1}\right)\\
   &= \frac{(n+1)!}{(i+1)!}{(n-i)!} = \binom{n+1}{i+1},
\end{align*}
which by the inductive hypothesis is the sum of two integers.

Since~$p$ is prime, it suffices to show that there is no factor of~$p$
in the denominator.  By assumption, $r<p$ so $p\nmid r!$, and similarly
$1\leq r$ implies that $p-r\leq p-1<p$, so $(p-r)!$ also contains no
factor of~$p$.


\item[\chap.\ref{ex:gcds}]
The $\gcd$s are $5$, $13$, $3$, $8$.  E.g.,
$
  \gcd(15,35) =\gcd(15,5)=\gcd(5,0)=\mathbf{5}.
$

\item[\chap.\ref{ex:sumn}]
\begin{enumerate}
\item The base case is trivial.  If the statment is true for~$n$, then
$$
  1 + \cdots + (n+1) = \frac{n(n+1)}{2}+(n+1) = \frac{(n+1)(n+2)}{2},
$$
as desired.  
\item If $n$ is even group the terms as $(1-2)+(3-4)+\cdots+(n-1-n)=-\frac{n}{2}$, 
and if $n$ is odd we have
$1+(-2+3)+(-4+5)+\cdots+(-(n-1)+n)=\frac{n+1}{2}$, so 
the general formula is
$(-1)^{n+1}\lceil\frac{n}{2}\rceil$.
\end{enumerate}


\item[\chap.\ref{ex:gcdrep}] The Euclidean algorithm gives
$2261 = 1275\cdot 1+986$, $1275=986\cdot 1 + 289$, 
$986 = 289\cdot 3 + 119$, $289=119\cdot 2 + 51$,  and
$119=51\cdot 2 + 17$, so
\begin{align*}
 17 &= 119 - 51\cdot 2 = (986-289\cdot 3)-(289-119\cdot 2)\cdot 2\\
    &= 986 - (1276 - 986)\cdot 3 - (1275 - 986)\cdot 2 + 
           (986 - 289\cdot 3)\cdot 4\\
    &= 1275\cdot(-5) + 986\cdot 10 + 289\cdot(-12)=
    1275\cdot(-17) + 986\cdot 22\\
    &= \mathbf{22}\cdot 2261 - \mathbf{39}\cdot 1275.
\end{align*}

\item[\chap.\ref{ex:polrepconj}]
See Theorem~\ref{thm:dirichlet} for the case $\deg(f)=1$,
and \cite[\S{}A.1]{guy:unsolved} when $\deg(f)=2$.
In general, if there is a prime~$p$ such that~$f$
induces the~$0$ function on $\Z/p\Z$, then $p\mid f(n)$
for all integers~$n$, so~$f$ does not take on infinitely many
values.  Thus, for example, $f=x^2+x+2$ is irreducible, but takes on
only finitely many prime values.  If there is no such~$p$ and~$f$
is irreducible, then the author optimistically 
suspects that~$f$ takes on infinitely many prime values.

\item[\chap.\ref{ex:howhard}] Easy.

\item[\chap.\ref{ex:primesform}]
First we note that all odd integers are congruent to $\pm 1$ or $3$
modulo~$6$, and if $x\con 3\pmod{6}$, then $3\mid x$.  Therefore all
odd primes (except~$3$) are congruent to $\pm 1$ modulo~$6$.
Next we note that if $p, q\con 1\pmod{6}$, then $pq\con 1\pmod{6}$.
Therefore if $n\con -1\pmod{6}$, then~$n$ must have a prime factor 
$p\con-1\pmod{6}$.  Let~$T=\{5,11,\ldots\}$ be the set of 
all primes $p\con -1\pmod{6}$. If~$T$ is finite, it makes sense
to consider the product $\Pi_0$ of the primes in~$T$. 
Since $\Pi = 6\Pi_0-1 \con -1\pmod{6}$ there is a prime $q\in T$
such that $q\mid \Pi$.  But for all $p\in T$, $\Pi\con -1\pmod{p}$,
a contradiction.  Thus~$T$ is infinite.

\item[\chap.\ref{ex:pnt}]
\begin{enumerate}
\item  E.g., $\pi(2002)=303$.
\item  For $x=2001$, $x/\log(x)\approx 263$, so the values differ by
about~$40$.
\end{enumerate}


\item[\chap.\ref{ex:residues}]
(a) $\{0,1,2,3,4,5,6\}$,
(b) $\{1,3,5,7,9,11,13\}$,
(c) $\{0,2,4,6,8,10,12\}$, and
(d) $\{2,3,5,7,11,13,17\}$.

\item[\chap.\ref{ex:invmod}] $71$.

\item[\chap.\ref{ex:ordmod}] $36$.

\item[\chap.\ref{ex:facphi}] $2^7\cdot 3^2$.

\item[\chap.\ref{ex:crt}] $302$.

\item[\chap.\ref{ex:pow}] $343$.

\item[\chap.\ref{ex:pow2}] $61$.

\item[\chap.\ref{ex:wilson2}]
It suffices to prove that the congruence holds modulo 
each prime power $p_i^{r_i}$
appearing in the prime factorization 
$p_1^{r_1}\cdots p_m^{r_m}$ of~$n$.
If $m>1$, then $p_i^{r_i}<n$, so 
$p_i^{r_i}\mid (n-1)!$, as required.  
It remains to consider the case when $m=1$
and $n=p^r$ is a prime power.  
We have 
$2p\leq p^r-1$ and $p^{r-1}\leq p^r - 1$, unless $p^r=2^2$, which
is not the case by assumption.  Also, $2p\neq p^{r-1}$,
unless $p=2$ and $r=3$, in which case one can check
the statement we are proving directly.  Thus
$$
  p^r \mid 2p\cdot p^{r-1} = 2p^r \mid (p^r - 1)!.
$$

\item[\chap.\ref{ex:phiodd}] $\vphi(n)$ is odd only 
for $n=1,2$, as one
sees by using the multiplicativity of $\vphi$ and that
if $p^r>2$ is a prime power, then
$\vphi(p^r)=p^r-p^{r-1}=(p-1)p^{r-1}$ is even.

\item[\chap.\ref{ex:div11}] 
We use that $10\con -1\pmod{11}$ and facts about modular arithmetic.
Write $n = \sum_{i=0}^r d_i 10^i$. Then 
$n \con \sum_{i=0}^r (-1)^i d_i\pmod{11}$, so $n\con 0\pmod{11}$ if and
only if the alternating sum of the digits $\sum (-1)^i d_i$ is congruent
to $0$ modulo~$11$.

\item[\chap.\ref{ex:phimult}] 
For the first part, the  answer is $n=1,2$.  On a
previous homework we proved that $n=1,2$ are the only~$n$ such that
$\vphi(n)$ is odd.  For the second part, the fact that $\vphi$ is
multiplicative means that if $\gcd(m,n)=1$ then
$\vphi(mn)=\vphi(m)\cdot\vphi(n)$.  When $\gcd(m,n)\neq 1$ this implication
can fail; for example, 
$
2 = \vphi(2\cdot 2)\neq \vphi(2)\cdot
\vphi(2)=1.
$
\end{solutions}


\begin{solutions}{ch:crypto}{2}
\item[\chap.\ref{ex:crypto1}] The secret code is 
 $s=g^{mn}=454^{1208}= 2156$ (all modulo $3793$).
 
\item[\chap.\ref{ex:crypto2}] 
\begin{enumerate}
\item $5384375093542$
\item $13$, since the word with~$n$ $Z$s corresponds to $27^n-1$
and $13$ is the greatest integer~$n$ such that $27^n-1<10^{20}$.
\end{enumerate}

\item[\chap.\ref{ex:crypto3}] 
The numbers they chose are tiny, so we can write a 
program to very quickly compute~$n$ and~$m$ (simply try
all posibilities $\leq 96$).  We find that $n=70$ and $m=31$, 
so $s=5^{70\cdot 31} = 44$.

\item[\chap.\ref{ex:crypto5}] 
\begin{enumerate} 
\item Using a computer, we find that 
$5352381469067 = 141307\cdot 37877681$, 
so $\vphi(n) = (141307-1)\cdot (37877681-1)=5352343450080$. 
The inverse of $e=4240501142039$ modulo
$\vphi(n)$ is $d=5195621988839$.
\item We have $3539014000459^d =18464$, which encodes
\verb*|WHY|.
\end{enumerate}


\item[\chap.\ref{ex:crypto6}] 
Encrypting every letter individually is not a secure method. Rather,
it is as secure as using a table of mappings of every letter to a number
on both ends. This sort of encryption is very susceptible to word
frequency examination.

\item[\chap.\ref{ex:crypto7}] 
\begin{enumerate}
\item 
Let $m=ed-1=38334587566167741692779486096$.  We
find that $a^{m/2}\con 1\pmod{n}$ for several random choices of~$a$.
Replace~$m$ by $m/2=19167293783083870846389743048$.
Again, we find that $a^{m/2}\con 1\pmod{n}$ 
for several random~$a$.
Upon replacing~$m$ by $m/2=9583646891541935423194871524$, we
find that $2^{m/2}\con 1433811615146880\pmod{n}$.
Unfortunately, $\gcd(2^{m/2}-1,n)=1$, so we try $3^{m/2}$, 
$5^{m/2}$, and finally find that
$p=\gcd(7^{m/2}-1)=37865717$, which is a nontrivial factor of~$n$.
Setting $q=n/p=37865693$, we have that $n=pq$.
\item
Letting $t=\lfloor \sqrt{n}\rfloor = 37865704$, we have
$\sqrt{t^2-n} \approx 8702.37$ and
$\sqrt{(t+1)^2-n} \approx 12.00$, so already we see that
$p=t+1+12 = 37865717$ and 
$q=t+1-12 = 37865693$.
\end{enumerate}


\item[\chap.\ref{ex:crypto8}] 
Since $2^n\con 6\pmod{13}$, a table of powers of $2$ modulo~$13$
quickly reveals that~$n$ must be~$5$ (we solve the discrete log problem
easily in this case since $13$ is so small).  Likewise, since 
$g^m\con 11\pmod{13}$ we see that $m=7$.  The secret key is $s=7$ 
since $g^{nm}=2^{35} \con 2^{11} \con 7\pmod{13}.$

\item[\chap.\ref{ex:crypto9}] 
  \begin{enumerate}
  \item We must compute $4^7\pmod{77}$.  Working modulo~$77$, we have that
    $$4^7 = 64\cdot 64 \cdot 4 = 13^2\cdot 4 = 169\cdot 4 = 15\cdot 4 = 60,$$
   so $4$ encrypts as  60.
  \item 
       First, $\vphi(n) = \vphi(77)=\vphi(7)\cdot\vphi(11)=6\cdot 10=60$.
       We then use the extended Euclidean algorithm to 
       find an integer~$e$ such that $7e\con 1\pmod{60}$. We find that
       $2\cdot 60 -17\cdot 7=1$, so $e=-17$ is a solution.
  \end{enumerate}


\end{solutions}

\begin{solutions}{ch:reciprocity}{3}
\item[\chap.\ref{ex:rec1}] 
$\kr{3}{97}={(-1)}^{48}\cdot
\kr{97}{3}=\kr{1}{3}=\mathbf{1}$,
$\quad \kr{5}{389}={(-1)}^{2}\cdot
\kr{389}{5}=\kr{4}{5}=\mathbf{1}$,
$\quad\kr{2003}{11}=\kr{1}{11}=\mathbf{1}$, and
$\quad \kr{5!}{7}=\kr{120}{7}=\kr{1}{7}=\mathbf{1}$.

\item[\chap.\ref{ex:rec2}] 
By quadratic reciprocity
$\kr{3}{p}={(-1)}^{\frac{p-1}{2}}\cdot
\kr{p}{3}$.   Since ${(-1)}^{\frac{p-1}{2}}$ only depends
on $p\pmod{4}$ and $\kr{p}{3}$ only depends on $p\pmod{3}$,
their product depends only on $p\pmod{12}$, and the result follows
by checking that the statement is true for each 
possibility of~$p$ modulo~$12$.

\item[\chap.\ref{ex:rec3}] 
It is sufficient to give two distinct elements $a,b$
in $(\Z/2^n\Z)^*$ of order~$2$,  for if there was a primitive 
root~$g$,
then $g^{\phi(2^n)/2}=g^{2^{n-2}}$ cannot simultaneously be
congruent to~$a$ and~$b$ modulo~$2^n$. 
Put $a=-1$; since $n>2$, $-1$ has order~$2$ in $(\Z/2^n\Z)^*$.  
Set $b=2^{n-1}-1\in (\Z/2^n\Z)^*$; then
$
  b^2=(2^{n-1}-1)^2
     = 2^{2n-2}-2\cdot 2^{n-1}+1
    = 1.
$
Now $b\neq a$, since $b-a=2^{n-1}<2^n$,
and $b\neq 1$, since $n>2$. 
Therefore~$a$ and~$b$ are distinct elements of 
order~$2$ in $(\Z/2^n\Z)^*$, a
 contradiction.

\item[\chap.\ref{ex:rec4}] 
We will
construct an element~$g$ of $(\Z/{p^2}\Z)^*$ with order
$\vphi(p^2)=p(p-1)$.  
Let $g_0$ be a primitive root modulo~$p$, and 
let $g=g_0+pt$ for some~$t$ to be
determined.  By the binomial theorem 
$$
  g^{p-1}\equiv g_0^{p-1}+(p-1)pg_0^{p-2}t
         \equiv (1+kp)+p(p-1)g_0^{p-2}t \pmod{p^2},
$$ 
for some~$k$, since $g_0^{p-1}\equiv 1\pmod{p}$.  
Because $p-1$ and $g_0^{p-2}$ are both coprime
to~$p$, we can  choose~$t$ such that 
$n=k+(p-1)g_0^{p-2}t$ is nonzero modulo~$p$.  
Then $g^{p-1}\equiv 1+np\pmod{p^2}$
and $p\nmid n$, so the order of~$g$ in $(\Z/p^2\Z)^*$ does not
divide $p-1$. But it divides $p(p-1)$, and~$p$ is prime, so the
order of~$g$ is $p(p-1)$, and~$g$ is a primitive root
modulo~$p^2$.

\item[\chap.\ref{ex:rec5}] 
Let~$g$ be a primitive root modulo $p$. Since
$p\equiv 1 \pmod{3}$, 
$c=g^{(p-1)/3}$ has order~$3$. Therefore~$c$ is
a solution to 
$$
  x^3-1 = (x-1)(x^2+x+1) = 0,
$$
where all arithmetic is taking place in the
integral domain $\Z/p\Z$. 
Since $c\neq 1$, we have $c^2+c+1=0$.  
Thus $4c^2+4c+4=(2c+1)^2+3=0$, so $(2c+1)^2=-3$,
hence $\kr{-3}{p}=1$.

\item[\chap.\ref{ex:rec6}] 
The solution is similar to the solution of the
Exercise~\chap.\ref{ex:rec6}.  Let~$c$ in $(\Z/p\Z)^*$ be an element of
order~$5$.  Then $c^5-1=(c-1)(c^4+c^3+c^2+c+1)=0$ and $c\neq 1$ implies
that $c^4+c^3+c^2+c+1=0$.  Now
$$
  (c+c^4)^2+(c+c^4)-1=c^4+c^3+c^2+c+1=0,
$$
so $(2(c+c^4)+1)^2=4((c+c^4)^2+(c+c^4)-1)+5=5$.

\item[\chap.\ref{ex:rec7}] 
{\em All odd primes.} Let~$p$ be an odd prime and~$g$ 
a primitive root modulo~$p$.    Rewrite the sum as:
\begin{align*}
  \sum_{a=1}^{p-1}{\left(\frac{a}{p}\right)}
       &=\sum_{i=1}^{p-1}{\left(\frac{g^i}{p}\right)}
=\sum_{j=1}^{\frac{p-1}{2}}{\left(\frac{g^{2j}}{p}\right)}+\sum_{j=1}^{\frac{p-1}{2}}{\left(\frac{g^{2j+1}}{p}\right)}\\
 &=\sum_{j=1}^{\frac{p-1}{2}}{\left(\frac{g^{2j}}{p}\right)}+
\left(\frac{g}{p}\right)\sum_{j=1}^{\frac{p-1}{2}}{\left(\frac{g^{2j}}{p}\right)}=
\frac{p-1}{2}\left(1+\left(\frac{g}{p}\right)\right).
\end{align*}
Now
$\kr{g}{p}=-1$, for if 
$\kr{g}{p}=1$ then $g^{\frac{p-1}{2}}=1$, 
and~$g$ would not be primitive.  Therefore
$\sum_{a=1}^{p-1}\kr{a}{p}=0$.

\item[\chap.\ref{ex:rec8}] 
A good guess is to be $C\approx 0.37395$.  Using a computer, we can
write a program to check the first~$n$ primes to see if~$2$ is a
primitive root, and divide this total by~$n$ to see the behavior of
the ratio.  Artin conjectured that 
$$
 C = \prod_{n=1}^{\infty} \left( 1-\frac{1}{p_n(p_n-1)}\right),
$$
where $p_n$ is the $n$th prime.
%if(n\%p == 0, 0, znorder(Mod(n,p))==p-1);\\ A(n, d, gen=0,
%prim=0)=forprime(p=2,d,prim++;if(ispr(n,p),gen++));gen/prim\\ ?
%A(2,500000)*1.0\\ \%37 = 0.3738263758486205402282247580\\ ?
%x=1;forprime(p=2,100000,x=x*(1.0-1/(p*(p-1))));x*1.0


\item[\chap.\ref{ex:rec9}] 
First we use the law of quadratic reciprocity to decide whether
or not there is a solution.  We have
$$
\kr{5}{2^{13}-1} = (-1)^{2\cdot (2^{13}-2)/2}\kr{2^{13}-1}{5}
        = \kr{1}{5} = 1,
$$
so the equation $x^2\con 5\pmod{2^{13}-1}$ has at least one solution~$a$.
Since the polynomial $x^2- 5$ has degree two and $2^{13}-1$ is prime,
there are at most~$2$ solutions. Since $-a$ is also a solution and $a\neq 0$,
there are {\em exactly two solutions}.

\item[\chap.\ref{ex:rec10}] 
Fermat's Little Theorem implies that
$4^{48} = 2^{96} \con 1\pmod{97}.$

\end{solutions}



\begin{solutions}{ch:contfrac}{4}
%\item[\chap.\ref{ex:cf1}] 
\item[\chap.\ref{ex:cf2}] 
We establish both identities by induction.  
\begin{itemize}
\item Claim: $[a_n,a_{n-1},\ldots,a_1,a_0]=\frac{p_n}{p_{n-1}}$.
\begin{proof} Since $p_{-1}=1$ and $p_0=a_0$,
$[a_0]=\frac{p_0}{p_{-1}}$, which establishes the base case.  Now
suppose that $[a_{n-1},\ldots,a_0]=\frac{p_{n-1}}{p_{n-2}}$. Then
\begin{align*}
[a_n,a_{n-1},\ldots,a_0]&=a_n+\frac{1}{[a_{n-1},\ldots,a_0]}\\
      &=a_n+\frac{1}{\frac{p_{n-1}}{p_{n-2}}}
= a_n+\frac{p_{n-2}}{p_{n-1}}=\frac{a_np_{n-1}+p_{n-2}}{p_{n-1}}.
\end{align*}
The numerator is $p_n$, by definition.
\end{proof}
\item Claim: $[a_n,a_{n-1},\ldots,a_1]=\frac{q_n}{q_{n-1}}$.
\begin{proof} 
Since $q_0=1$ and $q_1=a_1$,
$[a_1]=\frac{q_1}{q_0}$, which establishes the base case.  Now
suppose that $[a_{n-1},\ldots,a_1]=\frac{q_{n-1}}{q_{n-2}}$. Then
\begin{align*}
[a_n,a_{n-1},\ldots,a_1]&=a_n+\frac{1}{[a_{n-1},\ldots,a_1]}\\
     &= a_n+\frac{1}{\frac{q_{n-1}}{q_{n-2}}}
= a_n+\frac{q_{n-2}}{q_{n-1}}=\frac{a_nq_{n-1}+q_{n-2}}{q_{n-1}}.
\end{align*}
The numerator is $q_n$, by definition.
\end{proof}
\end{itemize}


\item[\chap.\ref{ex:cf3}] 
 If we compute ${\tt ellj(t)}$ in PARI, where
$t=-0.5+0.3281996289i$ the result is 
{\tt 61.7142856...-6.2E-26I}.  The imaginary part is approximately~$0$, 
so we guess
the rational number that gives the real part.  The command
{\tt contfrac(61.7142856)} gives {\tt [61,1,2,2,178571]}, 
which suggests that a good guess for our rational number is 
the rational number $\frac{432}{7}$ represented by the continued
fraction $[61,1,2,2]$. 

\item[\chap.\ref{ex:cf4}] 
\begin{enumerate}
\item Let $\alpha=[\overline{2,3}]$.  Then
$\alpha=2+\frac{1}{3+\frac{1}{\alpha}}$, so
$3\alpha^2-6\alpha-2=0$.  Solving for~$\alpha$ yields
$1+\frac{\sqrt{15}}{3}$.

\item First we compute $\alpha=[\overline{1,2,1}]$.  This
gives $\alpha=1+\left(2+\frac{1}{(1+\alpha^{-1})}\right)^{-1}$. 
Solving for $\alpha$ yields $3\alpha^2-2\alpha-3=0$, so
$\alpha=\frac{1+\sqrt{10}}{3}$.  Now
$[2,\overline{1,2,1}]=2+\frac{1}{[\overline{1,2,1}]}$, so our
final answer is $\frac{5+\sqrt{10}}{3}$.

\item This is $[\overline{1,2,3}]^{-1}$.  As above, if
$\alpha=[\overline{1,2,3}]$ then
$\alpha=1+\left(2+\frac{1}{3+\frac{1}{\alpha}}\right)^{-1}$.  This
simplifies to $\alpha=7\alpha^2+8\alpha-3=0$, so
$\alpha=\frac{4+\sqrt{37}}{7}$.  Therefore our 
desired answer is $\frac{-4+\sqrt{37}}{3}$.
\end{enumerate}

\item[\chap.\ref{ex:cf5}] 
We use the command {\tt contfrac} in PARI to 
find the continued fraction then prove that the answer is correct.
\begin{enumerate}
\item We claim that $\sqrt{5}=[2,\overline{4}]$.  Let
$\alpha=[\overline{4}]$; then $\alpha=4+\frac{1}{\alpha}$, so
$\alpha=2+\sqrt{5}$.  Now
$[2,\overline{4}]=2+\frac{1}{2+\sqrt{5}}=\sqrt{5},$ as desired.
\item We claim that
$\frac{1+\sqrt{13}}{2}=[2,\overline{3}]$.  Let
$\alpha=[\overline{3}]$; then $\alpha=3+\frac{1}{\alpha}$, so
$\alpha^2-3\alpha-1=0$.  This gives
$\alpha=\frac{3+\sqrt{13}}{2}$.  Then
$[2,\overline{3}]=2+\frac{2}{3+\sqrt{13}}=\frac{1+\sqrt{13}}{2}.$
\item We claim that
$\frac{5+\sqrt{37}}{4}=[\overline{2,1,3}]$.  Let
$\alpha=[\overline{2,1,3}]$; then
$\alpha=2+\left(1+(3+\frac{1}{\alpha})^{-1}\right)^{-1}$, so
$4\alpha^2-10\alpha-3=0$.  Solving for $\alpha$ gives
$\frac{5+\sqrt{37}}{4}$, as desired.
\end{enumerate}

\item[\chap.\ref{ex:cf6}] 
\begin{enumerate}
\item First we compute $[\overline{2n}]$.  Let
$\alpha=\overline{[2n]}$; then $\alpha=2n+\frac{1}{\alpha}$. This
gives $\alpha^2-2n\alpha-1=0$, so $\alpha=n+\sqrt{n^2+1}$.  Now
$[n,\overline{2n}]=n+\frac{1}{\alpha}=n-(n-\sqrt{n^2+1})=\sqrt{n^2+1},$
as desired.
\item Using the previous part, we know that
$\sqrt{5}=[2,\overline{4}]$.  We can try successive convergents
until two agree up to four decimal places; once such convergent
is $682/305$.
\end{enumerate}

\item[\chap.\ref{ex:cf7}] 
In PARI, use {\tt convergents(contfrac(Pi))} to obtain the
convergents of the continued fraction of~$\pi$.  We can now test
convergents for property described in the problem, noting that
smaller denominators are more likely to work.  One convergent
that satisfies the property is $3/1$, since $\pi-3<.15$ and
$\frac{1}{\sqrt{5}}>.44$.  The next is $22/7$, since
$22/7-\pi<.002$ and $\frac{1}{49\sqrt{5}}>.009$.  A third is
$355/113$, since $355/113-\pi<.0000003$ while
$\frac{1}{113^2\sqrt{5}}>.00003$.


\item[\chap.\ref{ex:cf8}] 
In PARI, the command {\tt contfrac(exp(2))} gives
\begin{verbatim}
  [7,  2,1,1,3,18,   5,1,1,6,30,   8,1,1,9,42,  11,1,1,12,54,
       14,1,1,15,77, 17,1,1,18,78, 20,1,1,21,90,...]
\end{verbatim}
This suggests that after the initial $7$ terms, the $i$th group of 5
numbers (grouping after the initial $7$) is of the form 
$$
  3(i-1)+2,1,1,3i,18+12(i-1).
$$



\item[\chap.\ref{ex:cf9}] 
\begin{enumerate}
\item
We are looking for natural number solutions to
$n+1=x^2$, $\frac{n}{2}+1=y^2$.  Isolating~$n$ yields
$n=x^2-1=2(y^2-1)$, implying that $x^2-2y^2=-1$.  There are
infinitely many solutions $(x,y)$ to this equation if the period
of the continued fraction of $\sqrt{2}$ has odd order.  Indeed,
$\sqrt{2}=[1,\overline{2}]$.  For each $(x,y)$ we can take
$2(y^2-1)$ to find a unique (even)~$n$; thus there are infinitely
many~$n$ satisfying the desired property.
\item 
We compute list of convergents for the continued fraction
of $\sqrt{2}$.  The odd terms are of interest, and since we want
to find $n>389$, we want the denominator of the convergent to be
at least $14$.  The first two such convergents are $\frac{41}{29}$
and $\frac{239}{169}$, which yield $n=2(29^2-1)=1680$
and $n=2(169^2-1)=57120$.
\end{enumerate}

\item[\chap.\ref{ex:cf10}] 
If~$x$ and~$y$ are consecutive integers, then we
have $z^2=x^2+(x+1)^2=2x^2+2x+1$.  Multiplying by 2, we have
$2z^2=4x^2+4x+2=(2x+1)^2+1$.  Putting $u=2x+1$, we have $u^2-2z^2=-1$.
From the previous problem we know there are infinitely many
solutions to this equation for $u$ and $z$.  Each
solution $(u,z)$ gives a unique $(x,z)$, and
each of these solutions $(x,z)$ leads to a primitive Pythagorean
triple ($x$ and $x+1$ are coprime
and if either shares a nontrivial divisor with~$z$ then the third
must also share this divisor).
\end{solutions}

\begin{solutions}{ch:quadform}{5}

\item[\chap.\ref{ex:qf1}]
Since $-389$ is negative, it is not the sum of two squares.
Since $3\mid\mid12345$, we see that $12345$ is not the sum of two squares.  Since
$7\mid\mid91210$, it follows that $91210$ is not the sum of two squares. 
The fourth number is $729=27^2$, which is a 
perfect square.  Since $7\mid\mid1729$, we see that $1729$ is not the sum of two
squares.  Finally, $151\mid\mid68252$ and $151\equiv 3\pmod{4}$, 
so $68252$ is not the sum of two squares.

\item[\chap.\ref{ex:qf2}]
\begin{enumerate}
\item Given an input~$n$, the following PARI program breaks~$n$ up 
into two parts and looks for a sum of two squares representation.

\begin{verbatim}
{squares(n) = 
   local(y); 
   for(x=1,floor(sqrt(n)),
      y=sqrt(n-x^2);
      if(y-floor(y)==0, 
         return([x,floor(y)])
      )
   );
   return(0) 
};

{f(n) =
   for(x=1,n,
      a=squares(x);
      b=squares(n-x);
      if(a!=0 && b!=0, 
         return([a[1],a[2],b[1],b[2]])
      )
  )
}
\end{verbatim}

\item $2001=1^2+8^2+44^2$

\end{enumerate}


\item[\chap.\ref{ex:qf3}]
Answer: $625$.  There are two Pythagorean triples with
$25$ as the hypotenuse: $(7,24,25)$ and $(15,20,25)$.  This gives
two representations of $625$ as the sum of two squares.  Of course,
$25^2$ is a third.

\item[\chap.\ref{ex:qf4}]
The forward direction is trivial.  For the opposite
direction, suppose that~$n$ is the sum of two rational squares:
$n=(\frac{a}{b})^2+(\frac{c}{d})^2$, but that~$n$ 
is not the sum of two integer squares.  
Then there exists a prime~$p$ such that 
$p^r\mid\mid{}n$, where $p\equiv 3\pmod{4}$ and~$r$ is odd. 
Now, $nb^2d^2=(ad)^2+(bc)^2$, so
$nb^2d^2$ is the sum of two integer squares.  However, all the
prime factors of $b^2d^2$ have even exponent, so $p^s\mid\mid{}nb^2d^2$,
where~$s$ is odd, a contradiction.

\item[\chap.\ref{ex:qf5}]
Suppose $p=x^2+2y^2$, where~$p$ is an odd prime and~$x$ and~$y$ 
are integers.  Then $x^2+2y^2\equiv 0\pmod{p}$, so
$\left(\frac{x}{y}\right)^2\equiv -2\pmod{p}$ 
(since $\Z/p\Z$ is a field). From
XXX, $\kr{2}{p}=1$ if and only if $p\equiv \pm 1\pmod{8}$.  
Also, $\kr{-1}{p}=1$ if and only if 
$p\equiv 1 \pmod{4}$ (i.e., $p\equiv 1,-3 \pmod{8}$).  
Since $\kr{-2}{p}=\kr{-1}{p}\cdot\kr{2}{p}$, 
we have $\kr{-2}{p}=1$ if and only if $p\equiv 1,3\pmod{8}$. 

Conversely, suppose that $p\equiv 1,3 \pmod{8}$ is
prime.  Let~$r$ be such that $r^2\equiv -2 \pmod{p}$.  Taking
$n=\lfloor \sqrt{p} \rfloor$ and applying Lemma 1.3 from Lecture
21 (XXX), there exist integers $a,b$ with $0<b<\sqrt{p}$ such that
$$
  \left|-\frac{r}{p}-\frac{a}{b}\right|\leq
   \frac{1}{b(n+1)}<\frac{1}{b\sqrt{p}}.
$$ 
Let $c=rb+pa$; then
  $|c|<\frac{pb}{b\sqrt{p}}=\sqrt{p}$, 
so $2b^2+c^2<3p$.  Since
$c\equiv rb\pmod{p}$, we also have 
that $2b^2+c^2\equiv b^2(2+r^2)\equiv 0\pmod{p}$. 
Therefore $2b^2+c^2=p$ or $2p$.  If
$2b^2+c^2=p$ we are done.  If $2b^2+c^2=2p$ then~$c$ must be even
(else $2b^2+c^2$ is odd).  Putting $c=2d$, we have
$$
  2p=2b^2+c^2=2b^2+4d^2,
$$ 
so $p=b^2+2d^2$,  
as desired.


\item[\chap.\ref{ex:qf6}]
Let $T_m$ be the $m$th triangular number.  It is easy
to see by induction that $T_m=m(m+1)/2$.  Then
\begin{align*}
8T_m^2+0&=(2T_m)^2+(2T_m)^2,\\
8T_m^2+1&=2m^2(m+1)^2+1=[(m-1)(m+1)]^2+[m(m+2)]^2,\\
8T_m^2+2&=2m^2(m+1)^2+2=[m(m+1)-1]^2+[m(m+1)+1]^2.
\end{align*}

\item[\chap.\ref{ex:qf7}]
Of any four consecutive integers, there is one~$n$
such that $n\equiv -1\pmod{4}$.  Since all odd prime factors are
congruent to $\pm 1 \pmod{4}$,~$n$ must have some prime factor
$p\equiv -1\pmod{4}$ with odd exponent, so~$n$ is
not representable as the sum of two squares.

\item[\chap.\ref{ex:qf8}]
We first solve
\begin{align*}
  13x^2+36xy+25y^2&=(ax+by)^2+(cx+dy)^2\\  
                  &=(a^2+c^2)x^2+2(ab+cd)xy+(b^2+d^2)y^2,
\end{align*}
then check that $ad-bc=1$.  By inspection, we try $a=3,c=2$.
Then $b^2+d^2=25$ and $2b+3d=18$, which again by inspection is
satisfied by $b=4,d=3$.  Since $ad-bc=1$, the form is equivalent
to $x^2+y^2$.

As above, we solve
\begin{align*}
58x^2+82xy+29y^2&=(ax+by)^2+(cx+dy)^2\\
           &=(a^2+c^2)x^2+2(ab+cd)xy+(b^2+d^2)y^2,
\end{align*}
then check that $ad-bc=1$.  By inspection, we try $a=3,c=7$.
Then $b^2+d^2=29$ and $7b+3d=41$, which again by inspection is
satisfied by $b=2,d=5$.  Since $ad-bc=1$, the form is equivalent
to $x^2+y^2$. 

We know that $x=17,y=10$ satisfies $x^2+y^2=389$.  To find $x,y$ such
that $13x^2+36xy+25y^2$, We use the transformation above and solve for
$$17=3x+4y,\ 10=2x+3y.$$ The solution to this system is $x= 11$,
$y= -4$.  Indeed, 
$$
  13\cdot 11^2-36\cdot 11\cdot 4+25\cdot 4^2=389.
$$


\item[\chap.\ref{ex:qf9}]
The discriminants are equal: $-24=162^2-4\cdot
199\cdot 33=96^2-4\cdot 35\cdot 66$.  However, the forms are not
equivalent.  To see this, we first show that $35x^2-96xy+66y^2$
is equivalent to $2x^2+3y^2$.  As above, this means solving
\begin{align*}
 35x^2-96xy+66y^2&=2(ax+by)^2+3(cx+dy)^2\\
      &=(2a^2+3c^2)x^2+2(2ab+3cd)xy+(2b^2+3d^2)y^2
\end{align*}
in integers $a,b,c,d$ such that $ad-bc=1$.  By inspection we see that
$a=2$, $b=-3$, $c=3$, $d=-4$ is a solution, so the forms are equivalent.
Now we show the first form is not equivalent to $2x^2+3y^2$.  If
we try to solve for as above, we encounter the equation
$33=2b^2+3d^2$, which has no solutions over the integers (we can
just check $0\leq b\leq 5$).

\item[\chap.\ref{ex:qf10}]
\begin{itemize}
\item $D=-155$: The group $C_D$ has four elements, represented
by $[[1, 1, 39], [3, -1, 13], [3, 1, 13], [5, 5, 9]].$  By the structure
theorem, $\cC_{D}$ is isomorphic to either $C_2\cross{}C_2$
or $C_4$. It is easy to verify that $[1,1,39]$ is the identity.
From this we find that $[3,-1,13]$ has order~$4$, so $\cC_D\ncisom C_4$.
\item $D=-231$:
There are $12$ elements: $[1, 1, 58]$, $[2, -1, 29]$, $[2, 1, 29]$,
$[3, 3, 20]$, $[4, -3, 15]$, $[4, 3, 15]$, $[5, -3, 12]$, 
$[5, 3, 12]$, $[6, -3, 10]$,\\$[6, 3, 10]$, $[7, 7, 10]$, $[8, 5, 8]$,
so $\cC_{D}\ncisom C_{12}$ or $C_2\cross C_6$.  
The identity is $[1,1,58]$ and both $[2,-1,29]$ and
$[2,1,29]$ have order~~$6$, which is impossible in 
$C_{12}$, so $\cC_D\ncisom C_2\cross C_6$.

\item $D=-660$: There are eight elements: $[1, 0, 165]$, $[10, 10,
19]$, $[11, 0, 15]$, $[13, 4, 13]$, $[2, 2, 83]$, $[3, 0, 55]$, $[5, 0,
33]$, $[6, 6, 29].$  The first element is the identity,
and all others have order $2$, so 
$\cC_{-660}\ncisom C_2\cross{}C_2\cross{}C_2$.

\item $D=-12104$: There are forty-eight elements (and these can
take a while to compute!):
By the structure theorem,
$$
 \cC_D\ncisom C_{48}, C_4\cross C_{12}, \text{ or } C_2\cross C_{24}.
$$
The identity element is $[1,0,3026]$, and using it we find two
elements of order four: $[45,-26,71]$ and $[50,-36,67]$,
eliminating everything but $C_4\cross{}C_{12}$.

\item $D=-10015$: There are fifty-four elements (which 
take a while to compute!). Therefore 
$\cC_D\ncisom C_3\cross{}C_{18}$ or 
$C_{54}$. The identity is $[1,1,2504]$, and from
this we find that $[10,-5,251]$  and
$[10,5,251]$ have order $9$.  Thus $\cC_D$ cannot be 
$C_{54}$, so $\cC_D\ncisom C_3\times C_{18}$.
\end{itemize}
\end{solutions}



\begin{solutions}{ch:ell}{6}
\comment{\item[\chap.\ref{ex:ell1}] 
\begin{enumerate}
\item
\begin{center}
\psset{unit=0.01in}
\pspicture(-30,-150)(50,150)
%\psgrid[gridcolor=gray]

\psline[linewidth=0.03]{->}(-2,0)(5,0)\rput(5.2,0){$x$}
\psline[linewidth=0.03]{->}(0,-5)(0,5)\rput(0,5.25){$y$}

\pscurve[linecolor=blue]
(39.9, 153.)
(39.8, 152.)
(39.7, 151.)
(39.6, 150.)
(39.5, 149.)
(39.4, 148.)
(39.3, 147.)
(39.3, 146.)
(39.2, 145.)
(39.1, 144.)
(39.0, 143.)
(38.9, 142.)
(38.8, 141.)
(38.7, 140.)
(38.6, 139.)
(38.6, 138.)
(38.5, 137.)
(38.4, 136.)
(38.3, 135.)
(38.2, 134.)
(38.1, 133.)
(38.0, 132.)
(38.0, 131.)
(37.9, 130.)
(37.8, 129.)
(37.7, 128.)
(37.6, 127.)
(37.5, 126.)
(37.4, 125.)
(37.4, 124.)
(37.3, 123.)
(37.2, 122.)
(37.1, 121.)
(37.0, 120.)
(36.9, 119.)
(36.8, 118.)
(36.8, 117.)
(36.7, 116.)
(36.6, 115.)
(36.5, 114.)
(36.4, 113.)
(36.3, 112.)
(36.3, 111.)
(36.2, 110.)
(36.1, 109.)
(36.0, 108.)
(35.9, 107.)
(35.8, 106.)
(35.8, 105.)
(35.7, 104.)
(35.6, 103.)
(35.5, 102.)
(35.4, 101.)
(35.3, 100.)
(35.3, 99.5)
(35.2, 98.5)
(35.1, 97.5)
(35.0, 96.5)
(34.9, 95.5)
(34.9, 94.5)
(34.8, 93.5)
(34.7, 92.5)
(34.6, 91.5)
(34.5, 90.6)
(34.5, 89.6)
(34.4, 88.6)
(34.3, 87.6)
(34.2, 86.6)
(34.2, 85.6)
(34.1, 84.6)
(34.0, 83.6)
(33.9, 82.6)
(33.8, 81.6)
(33.8, 80.6)
(33.7, 79.6)
(33.6, 78.6)
(33.5, 77.6)
(33.5, 76.6)
(33.4, 75.6)
(33.3, 74.6)
(33.3, 73.6)
(33.2, 72.6)
(33.1, 71.6)
(33.0, 70.6)
(33.0, 69.6)
(32.9, 68.6)
(32.8, 67.6)
(32.8, 66.6)
(32.7, 65.6)
(32.6, 64.6)
(32.6, 63.6)
(32.5, 62.6)
(32.4, 61.6)
(32.4, 60.6)
(32.3, 59.6)
(32.2, 58.6)
(32.2, 57.6)
(32.1, 56.6)
(32.0, 55.6)
(32.0, 54.6)
(31.9, 53.6)
(31.9, 52.6)
(31.8, 51.6)
(31.7, 50.6)
(31.7, 49.6)
(31.6, 48.6)
(31.6, 47.6)
(31.5, 46.6)
(31.5, 45.6)
(31.4, 44.7)
(31.3, 43.7)
(31.3, 42.7)
(31.2, 41.7)
(31.2, 40.7)
(31.1, 39.7)
(31.1, 38.7)
(31.0, 37.7)
(31.0, 36.7)
(31.0, 35.7)
(30.9, 34.7)
(30.9, 33.7)
(30.8, 32.7)
(30.8, 31.7)
(30.7, 30.7)
(30.7, 29.7)
(30.7, 28.7)
(30.6, 27.7)
(30.6, 26.7)
(30.6, 25.7)
(30.5, 24.7)
(30.5, 23.7)
(30.5, 22.7)
(30.4, 21.7)
(30.4, 20.7)
(30.4, 19.7)
(30.4, 18.7)
(30.3, 17.7)
(30.3, 16.7)
(30.3, 15.7)
(30.3, 14.7)
(30.2, 13.7)
(30.2, 12.7)
(30.2, 11.7)
(30.2, 10.7)
(30.2, 9.71)
(30.2, 8.71)
(30.2, 7.71)
(30.1, 6.71)
(30.1, 5.71)
(30.1, 4.71)
(30.1, 3.71)
(30.1, 2.71)
(30.1, 1.71)
(30.1, 0.714)
(30.1, -0.285)
(30.1, -1.28)
(30.1, -2.28)
(30.1, -3.28)
(30.1, -4.28)
(30.1, -5.28)
(30.1, -6.28)
(30.1, -7.28)
(30.2, -8.28)
(30.2, -9.28)
(30.2, -10.2)
(30.2, -11.2)
(30.2, -12.2)
(30.2, -13.2)
(30.3, -14.2)
(30.3, -15.2)
(30.3, -16.2)
(30.3, -17.2)
(30.3, -18.2)
(30.4, -19.2)
(30.4, -20.2)
(30.4, -21.2)
(30.4, -22.2)
(30.5, -23.2)
(30.5, -24.2)
(30.5, -25.2)
(30.6, -26.2)
(30.6, -27.2)
(30.6, -28.2)
(30.7, -29.2)
(30.7, -30.2)
(30.8, -31.2)
(30.8, -32.2)
(30.8, -33.2)
(30.9, -34.2)
(30.9, -35.2)
(31.0, -36.2)
(31.0, -37.2)
(31.1, -38.2)
(31.1, -39.2)
(31.2, -40.2)
(31.2, -41.2)
(31.3, -42.2)
(31.3, -43.2)
(31.4, -44.2)
(31.4, -45.2)
(31.5, -46.2)
(31.5, -47.2)
(31.6, -48.2)
(31.7, -49.2)
(31.7, -50.2)
(31.8, -51.2)
(31.8, -52.2)
(31.9, -53.2)
(31.9, -54.2)
(32.0, -55.2)
(32.1, -56.2)
(32.1, -57.2)
(32.2, -58.2)
(32.3, -59.2)
(32.3, -60.2)
(32.4, -61.2)
(32.5, -62.2)
(32.5, -63.2)
(32.6, -64.2)
(32.7, -65.2)
(32.7, -66.2)
(32.8, -67.2)
(32.9, -68.2)
(32.9, -69.2)
(33.0, -70.2)
(33.1, -71.2)
(33.1, -72.2)
(33.2, -73.2)
(33.3, -74.2)
(33.4, -75.2)
(33.4, -76.2)
(33.5, -77.2)
(33.6, -78.2)
(33.7, -79.2)
(33.7, -80.2)
(33.8, -81.2)
(33.9, -82.2)
(34.0, -83.2)
(34.0, -84.2)
(34.1, -85.2)
(34.2, -86.2)
(34.3, -87.2)
(34.4, -88.2)
(34.4, -89.2)
(34.5, -90.1)
(34.6, -91.1)
(34.7, -92.1)
(34.7, -93.1)
(34.8, -94.1)
(34.9, -95.1)
(35.0, -96.1)
(35.1, -97.1)
(35.1, -98.1)
(35.2, -99.1)
(35.3, -100.)
(35.4, -101.)
(35.5, -102.)
(35.6, -103.)
(35.6, -104.)
(35.7, -105.)
(35.8, -106.)
(35.9, -107.)
(36.0, -108.)
(36.1, -109.)
(36.1, -110.)
(36.2, -111.)
(36.3, -112.)
(36.4, -113.)
(36.5, -114.)
(36.6, -115.)
(36.6, -116.)
(36.7, -117.)
(36.8, -118.)
(36.9, -119.)
(37.0, -120.)
(37.1, -121.)
(37.1, -122.)
(37.2, -123.)
(37.3, -124.)
(37.4, -125.)
(37.5, -126.)
(37.6, -127.)
(37.7, -128.)
(37.7, -129.)
(37.8, -130.)
(37.9, -131.)
(38.0, -132.)
(38.1, -133.)
(38.2, -134.)
(38.3, -135.)
(38.4, -136.)
(38.4, -137.)
(38.5, -138.)
(38.6, -139.)
(38.7, -140.)
(38.8, -141.)
(38.9, -142.)
(39.0, -143.)
(39.0, -144.)
(39.1, -145.)
(39.2, -146.)
(39.3, -147.)
(39.4, -148.)
(39.5, -149.)
(39.6, -150.)
(39.7, -151.)
(39.7, -152.)
(39.8, -153.)
(39.9, -154.)
\endpspicture
\end{center}
\end{enumerate}
}

\item[\chap.\ref{ex:ell2}] 
Differentiating implicitly, the slope of the tangent
at $(x,y)$ is $\frac{3x^2}{2y}$.  At $(3,5)$, the slope is
$\frac{27}{10}$, and the tangent line has equation
$y=\frac{27x-31}{10}$.  Substituting into the relation
$y^2-x^3=-2$, we have $\left(\frac{27x-31}{10}\right)^2-x^3=-2$, which
simplifies to the polynomial 
$$
 100x^3-729x^2+1674x-1161=0.
$$ 
This polynomial has a double root at $x=3$, so it factors as
$(100x-129)(x-3)^2$, giving a rational root with $x=129/1000$.
Therefore $(129/100, 383/1000)$ is a rational solution to the original
equation.

\item[\chap.\ref{ex:ell3}] 
The transformation
$$
 x \mapsto X-\frac{1}{12},\qquad
 y \mapsto -\frac{1}{2}X + Y - \frac{11}{24}.
$$
transforms $y^2 +xy+y = x^3$ into
$$
  Y^2 = X^3 + \frac{23}{48} X +\frac{181}{864}.
$$


\item[\chap.\ref{ex:ell4}] 


\item[\chap.\ref{ex:ell5}] 
\begin{enumerate}
\item In general there is no identity element.  Suppose
to the contrary that $\O$ is the identity, and suppose
that~$P$,~$Q$, and~$\O$ are distinct and colinear.  
Then $P\boxplus \O = Q \neq P$, so $\O$ is not the identity.
The inverse axiom sort of works, in that if $\O$ were
the identity and $P\in E(\R)$, then there is $Q$ such
that $P+Q=\O$.  Associativity fails; for example,
consider $y^2 = x^3+1$.  We have
$((-1,0)\boxplus (0,1))\boxplus (0,-1) = (2,3)$,
yet 
$(-1,0)\boxplus ((0,1)\boxplus (0,-1)) = (-1,0)$.
\item 
Note that $P \boxplus Q = - (P+Q)$, where $+$ is the
usual group law.  Thus if 
$E(\Q)\in \{\{0\}, \Z/2\Z, (\Z/2\Z)^2\}$,
then $(E(\Q),\boxplus)$ is a group.  Otherwise it isn't,
because there is no identity, as mentioned above.
\end{enumerate}


\item[\chap.\ref{ex:ell6}] 

\item[\chap.\ref{ex:ell7}] 

\item[\chap.\ref{ex:ell8}] 

\item[\chap.\ref{ex:ell9}] 

\item[\chap.\ref{ex:ell10}] 

\item[\chap.\ref{ex:ell11}] 

\item[\chap.\ref{ex:ell12}] 

\item[\chap.\ref{ex:ell13}] 

\end{solutions}


\comment{

\item Since $2^n\con 6\pmod{13}$, a table of powers of $2$ modulo~$13$
quickly reveals that~$n$ must be~$5$ (we solve the discrete log problem
easily in this case since $13$ is so small).  Likewise, since 
$g^m\con 11\pmod{13}$ we see that $m=7$.  The secret key is $s=7$ 
since $g^{nm}=2^{35} \con 2^{11} \con 7\pmod{13}.$
(Some people who attempted this problem incorrectly thought the secret key 
should be $g^n\cdot g^m = g^{n+m}$.)
\item 
  \begin{enumerate}
  \item We must compute $4^7\pmod{77}$.  Working modulo~$77$, we have that
    $$4^7 = 64\cdot 64 \cdot 4 = 13^2\cdot 4 = 169\cdot 4 = 15\cdot 4 = 60,$$
   so $4$ encrypts as 60.
  \item 
       First, $\vphi(n) = \vphi(77)=\vphi(7)\cdot\vphi(11)=6\cdot 10=60$.
(Some people incorrectly thought that $\vphi(n)=77$ for some reason.)
We then use the extended Euclidean algorithm to 
find an integer~$e$ such that $7e\con 1\pmod{60}$. We find that
$2\cdot 60 -17\cdot 7=1$, so $e=-17$ is a solution.
  \end{enumerate}

\item First we use the law of quadratic reciprocity to decide whether
or not there is a solution.  We have
$$
\kr{5}{2^{13}-1} = (-1)^{2\cdot (2^{13}-2)/2}\kr{2^{13}-1}{5}
        = \kr{1}{5} = 1,
$$
so the equation $x^2\con 5\pmod{2^{13}-1}$ has at least one solution~$a$.
Since the polynomial $x^2- 5$ has degree two and $2^{13}-1$ is prime,
there are at most~$2$ solutions. Since $-a$ is also a solution and $a\neq 0$,
there are {\bf exactly two solutions}.
\item (a) has {\bf no solutions} because $x\con -1\pmod{9}$ implies that
$x\con -1\pmod{3}$.  (b) has {\bf a solution} because
 $\gcd(2,1234567891011121314151)=1$.  
(c) has {\bf a solution} because $\kr{5}{29}=\kr{3}{47}=1$ so there are
$a$ and $b$ such that $a^2\con 5\pmod{29}$ and $b^2\con 3\pmod{47}$;
the Chinese Remainder Theorem then implies that there is an~$x$ such
that $x\con a\pmod{29}$ and $x\con b\pmod{47}$.  (d) has {\bf a solution}
by the Chinese Remainder Theorem, since $\gcd(29,47)=1$.  
(e) has {\bf no solution} 
since $\kr{3}{29}=-1$, so the first of the two equations
doesn't even have a solution.
\item Since $97$ is prime, Fermat's Little Theorem implies that
$4^{48} = 2^{96} \con \mathbf{1}\pmod{97}.$

}










