# PreLab 06

Due in class on Wednesday, October 11

This is a little shorter most of our prelabs.

## Recursive Output

Work out by hand what the following function will do. If you want to check your answer by typing the function into Python, that is fine, but you need to be able to think about recursive functions without running them. Start by computing strange(0), then strange(1), strange(2), and so forth.

### Function strange

```   def strange(x) :
if x <= 0 :
return 1
else :
return 5 * strange(x-1) - 2
```
1) What is the output of print(strange(3)) ?

## Geometry

You will need this for one of the recursive pictures. Consider the following figure. Let (Ax, Ay) be the coordinates of point A, (Bx, By) those of point B, and (Cx, Cy) those of point C. The points P, Q and R are the midpoints of the three edges of the big triangle.

2) Specify the x and y coordinates of P, Q and R in terms of the coordinates of A, B and C. Don't assume that any coordinates are 0 or that there is any relationship between the points (the triangle ABC pictured happens to be fairly symmetric, but you shouldn't assume this will necessarily be the case).

## Recursion on strings

3) Write a recursive function noSpace( s ) that takes string s and returns a string like s with all of the spaces removed. So noSpace( "Bob Geitz" ) returns "BobGeitz" and noSpace( "A B C D" ) returns "ABCD". When you recurse you break the string into 2 parts: s[0[ is the first letter of s, and s[1:] is all of x except for the first letter.

## Honor Code

If you followed the Honor Code in this assignment, write the following sentence attesting to the fact at the top of your homework.

I affirm that I have adhered to the Honor Code in this assignment.