# PreLab 05

Due in class on Wednesday, October 7

This is a little different from most of our prelabs. The last two questions have nothing to do with Lab 5; they are just here to help you prepare for Friday's exam.

## Part 0 - 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..

### 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))

## Part 1 - Geometry

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).

The following two questions have nothing to do with the lab or with recursion. This will give you some practice writing code on paper, which is a skill that a lot of beginning programming students struggle with. If you want to use helper functions to solve either of these you are welcome to, but naturally you need to write the helpers as well.

3) Write a program that has an input loop in which the user enters integers. When the input is 0 the loop should halt and the program should print the sum of all of the numbers that were entered.

4) Write a function primeCount(a, b). You can assume this will be called with integer arguments a and b with a < b. The function should return the number of primes between a and b (including both endpoints). For example, if you call primeCount(10, 19) it returns 4 because there are 4 primes between 10 and 19 (they are 11, 13, 17, 19).

## 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.