COMP203: Assignment 5


Use the Assignment Manager to turn in your homework. If you get stuck, try following the instructions for students at http://blackboard.bridgew.edu/faculty_help/assignmang.cfm. Please include your full name and the assignment number in your document. Please format your assignment so that it is easy to copy and paste blocks of code into Logo.
  1. Define the following recursive Logo procedure:
    to countdown :number
     print :number
     countdown :number-1
     if equalp :number 0 [stop]
    end
    
    This procedure is supposed to look like this when run:
    ? countdown 5
    5
    4
    3
    2
    1
    0
    ?
    
    Try it -- it doesn't work! Use the Logo menu to stop the procedure.

    Why doesn't the procedure work?

  2. Edit the countdown procedure so that it works as intended.

  3. Write a recursive procedure sumup that takes a positive integer n as input and outputs the sum 1 + 2 + 3 + ... + n. You may find it helpful to review the initials.recursive procedure from Lecture 13.

Bonus (5 pts) Write a recursive procedure triangleview that draws a collection of nested triangles similar to those shown below.