Math functions

Exercise 1

By hand calculation, find the Collatz sequences for 1, 2, 3, and 4. Use DrScheme to find the Collatz sequences for 25, 26, 27, and 28.

Exercise 2

Is the prime-factors-kernel procedure presented in the reading on indefinite recursion tail-recursive? If so, explain why. If not, explain why not and develop and test a tail-recursive version of it.

Exercise 3

Trace through the execution of (Euclid-GCD 34 21). Note that 21 and 34 are consecutive Fibonacci numbers. What is the GCD of any two consecutive Fibonacci numbers? Test you answer by calculating (Euclid-GCD (Fibonacci 1001) (Fibonacci 1000)).


This document is available on the World Wide Web as

http://www.cs.grinnell.edu/~gum/courses/151/labs/math-functions.xhtml

created March 2, 1997
last revised February 24, 2002

John David Stone (stone@cs.grinnell.edu) and Ben Gum (gum@cs.grinnell.edu)