[Santa Clara University]
Department of Mathematics
and Computer Science

Machine Problem 4

Math 169
D. C. Smolarski, S.J.
Fall 2007

                              
Language: LISP
30 points
DUE: Noon, Monday, November 26, 2007

Gentle Reminder: The program is to be done individually, without any collaboration! See the information found on the web page: General Rules and Other Information.

This program should be done using LISP on math. You can use a PC version for testing preliminary functions, but the final version should be executed on math.

Part I - Factorial Problem.

Read in an arbitrary number of numbers. FOR SIMPLICITY'S SAKE, YOU CAN DEFINE A LIST OF NUMBERS. For the integers between 0 and 10 calculate their square and factorial and print the results in reverse order. In other words, if the first element of the list is 3, then 3x3 = 9 and 3! = 6 should be the last values outputted. If the integers are negative or greater than 10 print an appropriate error message. The input file/list should be 3, -2, 6, 10, 25.

Part II - LISP SPECIFIC PROBLEM.

Write an ITERATIVE lisp function to calculate factorials, and find 1000! . (If you use XLISP, you can only calculate 8!.)

(I usually give a longer program which really forces people to get into the technical aspects of LISP, but I don't want to fry your brains at this point of the quarter!)

You should record a session at the terminal via the Unix/Linux script system function to show that your function does what it is suppose to do.

Turn in your file containing your LISP functions for each part of the assignment and a "script" file showing that each of your functions actually produces the desired output.


This page is maintained by Dennis C. Smolarski, S.J. dsmolarski@math.scu.edu
© Copyright 2007 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 8 November 2007.