# ICS 1F, Homework 1 Solutions

1. List three things you think computers can now do better than you, and three things you think you can do better than computers.

My answer: Computers can play chess, perform arithmetic, and predict weather better than I can. I can speak English, make new mathematical discoveries, and program computers better than computers can.

2. Is there a (whole number) value of x that would cause an infinite loop in the procedure described below? Explain why or why not. (Hint: Try it with a few small numbers to see what happens.)

```    Read a number x.
Initialize a counter to zero.

While x is greater than zero, perform the following steps:

Increase the counter by one.
If x is odd, replace x by (x+1)/2;
otherwise (if x is even) replace x by x-2.

Once the loop terminates (if it does),
output the value of the counter and halt.
```
Answer: If x=1, then (x+1)/2 is also 1, so the program goes into an infinite loop.

3. In the imaginary country of Binaria, the currency is based on the centina, which is worth approximately the same as a penny. The coins of Binaria have values that are powers of two: 1, 2, 4, 8, 16, 32, and 64 centinas.

(a) What coins should you use to make change for the following amounts of money? (In each case answer with the smallest possible set of coins that adds up to the correct value.)

1. 15 centinas
2. 29 centinas
3. 39 centinas
4. 108 centinas