%-------------------------------------------------------
% exercise2.tex
%    Exercise 2.
%
% Irit Dinur
%--------------------------------------------------------

\documentclass[12pt]{article}
%\documentclass[twocolumn]{article}
\usepackage{alltt,url,amstext,amsmath,amssymb}

\setlength{\evensidemargin}{.0in}
\setlength{\oddsidemargin}{-0.3in}
\setlength{\textwidth}{6.8in}
\setlength{\textheight}{8.7in}

\newcommand{\sep}[1]{\,\left|\, {#1} \MakeBig\right.}
\newcommand{\brc}[1]{\left\{ {#1} \right\}}
\newcommand{\pth}[1]{\left( {#1} \right)}
\newcommand{\ceil}[1]{\left\lceil {#1} \right\rceil}
\newcommand{\floor}[1]{\left\lfloor {#1} \right\rfloor}

\newcommand{\remove}[1]{}
\newtheorem{theorem}{Theorem}[section] % section
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{example}[theorem]{Example}
\newtheorem{defn}[theorem]{Definition}
\newcommand{\ctrl}{{\symbol{'136}}}
\newcommand{\examplex}[3]{
    \vspace{0.2cm}
    \noindent{\tt #1}

    \noindent{\bf \large Input:}
    {\tt #2}

    \noindent{\bf \large Output:}{\tt #3}

    \vspace{0.2cm}
}
\newcommand{\exmpinp}{\noindent{\bf \large Input:}\vspace{-0.3cm}}
\newcommand{\exmpout}{\noindent{\bf \large Output:}\vspace{-0.3cm}}
\newcommand{\MakeBig}{\rule[-.2cm]{0cm}{0.6cm}}
\newcommand{\unix}{{\tt UNIX}}
\newcommand{\dos}{{\tt DOS}}

\newcommand{\exercise}[2]{\section*{Ex {#1} ~ {#2}}}

\newcommand{\tildegen}{\protect\raisebox{-0.12cm}{\symbol{'176}}}
\newcommand{\atgen}{\symbol{'100}}
\newcommand{\email}{{\tt sariel\atgen{}math.tau.ac.il}}
\newcommand{\homepage}{{\tt http://www.math.tau.ac.il/\tildegen{}sariel/}}


% Title
\title{Introduction to Computer Science - Fall Semester 1998/9\\
   { {{Exercise}} 2}}

\author{{\bf Due:} 31/12/1998}

\date{}

\begin{document}
\maketitle


\exercise{1.1}{zyx..}
Write a program that outputs the letters of the English alphabet in reverse.

\exercise{1.2}{Counting letters}
Write a program that asks the user for a sequence of letters and then
counts the number of times the first three letters of the alphabet
(a,A,b,B,c,C) occur. Do not distinguish between lower-case and
upper-case letters.

\exercise{1.3}{exp}

Write a program that reads a real number $x$ from the input, computes, and 
outputs $\exp(x) = e^x$.  The value $\exp(x)$
should be computed according to the formula:
\[
exp(x) = 1 + \sum_{i=1}^{20} \frac{x^i}{i!}\;\;,
\]
where $i!=1\cdot 2 \cdot 3 \cdots i$. Note that the $i$-th element in
this summation can be easily computed from the $(i-1)$-st element.

\exercise{1.4 (bonus)}{Binary Representation}
The binary representation of a number $n$ is $b_kb_{k-1}\cdots b_0$
where $$n = b_0\cdot 2^0 + b_1\cdot 2^1 + \ldots + b_k\cdot 2^k$$
Write a program that asks the user for an integer and then prints out
its binary representation. (Hint: print first the reverse representation
$b_0b_1\cdots b_k$).
\end{document}



%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
