# Solutions to Practice Second Exam

### Directions:

• Answer the problems on the exam pages.
• There are four problems for 100 total points. Scale will be determined after the exam but a good guess is A = 90, C = 60.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.

Question text is in black, solutions in blue.

```  Q1: 15 points
Q2: 15 points
Q3: 20 points
Q4: 20 points
Q5: 30 points
Total: 100 points
```

• Question 1 (15): Briefly identify the following terms or concepts (3 points each):

• (a) for x to be a multiple of y

An integer x is a multiple of y if it equals yz for some integer z.

• (b) a proof by contradiction

A proof by contradiction is where you prove a proposition p by first assuming "not p", then using that and other true facts and valid proof methods to derive a contradiction. You have then proved "not p → 0", which is equivalent to p.

• (c) a rational number

A rational number is a real number that can be written in the form x/y, where x and y are integers and y ≠ 0.

• (d) the base case of a proof by induction

When we use induction to prove a statement P(n) for all positive integers n, the base case is to prove the proposition P(1).

• (e) a predicate on the positive integers

A predicate on the positive integers is some statement that contains one free variable of type "positive integer". If P(x) is such a statement, then P(1), P(2), P(3), etc. are propositions obtained by substituting each number for n in the definition of P(n).

• Question 2 (15): Determine whether each of these five statements is true or false. No explanation is needed or wanted, and there is no penalty for guessing.

• (a) 91 is not divisible by 7.

FALSE. Since 91 = 7 times 13, 91 is divisible by 7.

• (b) (31 mod 6) = (25 mod 4) (Remember that E&C's "mod" is the same as Java's "%" on non-negative integers.)

TRUE. Both divisions have remainder 1.

• (c) The binary representation of the decimal number "19" is "10101".

FALSE. 10101 is the binary for 16 + 4 + 1 = 21.

• (d) Every perfect square can be written as either "4k" or "4k+1" for some integer k.

TRUE. If n = 2m, then n2 = 4m2 which is divisible by 4. If n = 2m + 1, then n2 = 4m2 + 4m + 1 which is a multiple of 4, plus 1. By the Division Theorem these are the only two possible cases.

• (e) The square of every irrational number is irrational.

FALSE. We proved in lecture that the square root of 2 is irrational. So it is an irrational number whose square is rational.

• Question 3 (20): Prove that if k is any integer, the number 7k + 5 is not a perfect square. (Hint: Argue the contrapositive, and apply the Division Theorem with m = 7 to the number you are squaring.)

We will show that if n is any integer, then n2 is not of the form 7k + 5 because it has a remainder mod 7 of other than 5. Any integer n can be written as 7q + r where r is 0, 1, 2, 3, 4, 5, or 6. If r = 0, n2 = 49q2 which is a multiple of 7 and hence not of the form 7k + 5. If r = 1, m2 = 49q2 + 14q + 1, which has remainder 1, not 5, when divided by 7. In each of the other five cases, n2 = 49q2 + 14qr + r2. This number, when divided by 7, has the same remainder as does r2 because the other two terms are divisible by 7. With r = 2 this remainder is 4, with r = 3 it is 2 because (9 mod 7) = 2, with r = 4 it is (16 mod 7) = 2, with r = 5 it is (25 mod 7) = 4, and with r = 6 it is (36 mod 7) = 1. So it is never 5 for any perfect square.

• Question 4 (20): Define a number sequence so that a1 = 3 and for all k with k > 1, ak = ak-1 + 4k - 7. Prove by induction that for any positive integer n, an = 2n2 - 5n + 6.

For our base case, we must prove P(1), which says that a1 = 2(1)2 - 5(1) + 6. Since 2 - 5 + 6 = 3, this matches the given value of a1.

For the inductive case, we assume that ak-1 = 2(n-1)2 -5(n-1) + 6, which is 2n2 - 4n + 2 - 5n + 5 + 6 = 2n2 -9n + 13. Then, by the rule, an = an-1 + 4n - 7 = 2n2 -9n + 13 + 4n - 7 = 2n2 -5n + 6. This is exactly what the statement P(n) says that it should be.

• Question 5 (30): Define a number sequence so that b1 = 2, b2 = 3, and for all k with k > 2, bk = bk-1 - bk-2 + 1.

• (a, 5) Calculate bi for all integers i from i through 10.

b3 = 3 - 2 = 1, b4 = 1 - 3 = -2, b5 = -2 - 1 = -3, b6 = -3 - (-2) = -1, b7 = -1 - (-3) = 2, b8 = 2 - (-1) = 3, b9 = 3 - 2 = 1, and b10 = 1 = 3 = -2.

• (b, 5) Determine the value of b100. (Hint: I don't expect you to determine all the intermediate values -- find a pattern in part (a) or use the result of part (c).)

By the result of part (c), b100 = b94 = b88, and so on removing 6 at a time until we reach b4 = -2.

• (c, 20) Prove by induction that for any n with n > 6, bn = bn-6. (Hint: Prove the base cases of n = 7 and n = 8, then use the sequence definition in your inductive case.)

First base case: We observe that b7 and b1 are both 2.

Second base case: We observe that b8 and b2 are both 3.

Inductive case: Let n be any number with n > 8. We assume that bn-1 = bn-7, and that bn-2 = bn-8. We can do this because n-1 and n-2 are each greater than 6. Now the rule says that bn = bn-1 - bn-2, and by our two assumptions this equals bn-7 - bn-8. But by the rule again, this latter expression equals bn-6, so we have proved that bn = bn-6.