(modulo 21 6)
(modulo 57 13)
(modulo 23 2)
(modulo 24 2)
(modulo 0 2)
Note 1: in a
Scheme arithmetic calculation, if any one (or more)
of the numbers contain a decimal point, then the calculation will
be done using
decimals (and will probably be approximate). If all of the
numbers are
integers or fractions, and none of them contain a decimal point,
then the answer
will usually be exact, and may contain a fractional part. For
instance:
(/ 7 (+ 2 3)) ; -> 1 2/5
(/ 7 (+ 2.0 3)) ; -> 1.4
Note 2: Scientific notation can also be entered: for instance, 300.0 can be written 3e2
Note 3: Use
the semi-colon character ";" to start a comment in the upper
(definitions) pane. The comment will last unto the end of
the line. Example:
; This is problem # 12
(define pi 3.1415926535) (define r 3.2) (* pi r r)
; That was problem # 12======================= Homework exercises to hand in ==================================
1. Below, you'll see an object called a "continued
fraction". Evaluate the fraction in Scheme, and get the
result in
decimal.
Place the decimal answer (rounded to 5 decimal places) in the
comments-to-teacher section. (BTW, does the answer look familiar?)
2. Let's create a mathematical (not Scheme)
notation: "A (mod B)" is the
remainder when A is divided by B. Now let's notice a pattern
found by the
great mathematician Pierre de Fermat back in 1640. Evaluate
the 4 examples
below, each of which is in the form: XY (mod Z).
There's
nothing special about the choice of X, but there is something
special about the
choice of Z and of Y. Guess what's special about the
relationship between
Y and Z, and what's special about Z? Write a quick answer in
the
comments-to-teacher.
2a) evaluate 212 (mod 13)
2b) evaluate 522 (mod 23)
2c) evaluate 556 (mod 7)
2d) evaluate 1842 (mod 43)
3. a) One "Astronomical Unit" is defined to be the average distance from the Earth to the Sun. It is approximately 93 million miles. If light travels at approximately 186,000 miles/second, about how many minutes will it take light from the Sun to reach the Earth (round to 3 significant digits)? Write and evaluate a Scheme expression using these values (in the upper-pane), and put the answer into the Comments-to-teacher..
3. b) Once more, light travels at approximately 186,000 miles/second. How far does light go (in units of feet) in one billionth of a second (round answer to 2 significant digits)? Write and evaluate the Scheme expression and put the answer into the Comments-to-teacher.
3. c) Mr .Brooks asks Fred to calculate (and store, under his name) the distance in feet that light travels in a year (one light-year in feet), and then to give the answer to George, who should also store it under his name. (Note: I'd like you to use 365.242196 as the average number of days/year in your calculations). Fred, being mischievous, wants to keep the correct answer to himself, and so he adds one to his answer before giving it to George. Mr. Brooks suspects foulplay, and asks Fred and George for their answers and wants to calculate the difference between them. What is the answer that Mr. Brooks calculates? Put his answer into the Comments-to-Teacher.