Assignment Three
Functions

In this assignment you will build some functions.

Part One

Create a function which determines whether or not an integer is prime. This function should take one integer as a parameter, and return a boolean. Remember that a prime number is defined as any integer greater than one which is evenly divisible only by itself and one.

Part Two

Use the function you created in part one to create a function which prints out a table of the first n primes, where n is a number passed into the function. This function should take one parameter, the number of primes to print, and return nothing (void).

Part Three

Write a function which calculates the nth fibonnacci number. The fibonacci numbers are the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, .... Each number after the first two is calculated by adding together the previous two fibonnaci numbers. This function should take the desired number as its parameter, and return the chosen fibonacci number.

Part Four

Write a function which prints out the first n fibonnacci numbers. The function should take an integer, print out that many fibonnacci numbers in a chart, and return nothing.

What to turn in

Print out and turn in the code and any test runs of your results from parts two and four. If you are not able to complete parts two or four, but are able to complete one and/or three, turn those in instead along with appropriate testing of the function (you should have tested these functions before tackling parts two and four anyway!).

Turn these in at the beginning of class on 14 February, 2007.