Functions, Tests, and Looping

Assignment

These exercises cover basic use of functions. Remember that functions are defined by a def statement, accept inputs via arguments, and have somewhere inside their definition a return statement that returns the output.

  1. Write a function that returns the factorial of a number.
  2. Write a function that checks whether or not a vector of numbers is monotonically increasing (i.e. each subsequent element is greater than the one previous). It should return 1 if true and 0 if false.

Solution

See the following web page.

Creative Commons License Updated: Friday, 24-Dec-2010 08:44:09 PST. Valid CSS, HTML. Author: Johnny Lin <email address>. Disclaimer. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike License.