# Solutions to Second Midterm Exam

### Directions:

• Answer the problems on the exam pages.
• There are four problems for 100 total points. Actual scale was A = 90, C = 60.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.

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

Question text is in black, solutions in blue.

• Question 1 (20): Briefly identify the following terms or concepts (4 points each):

• (a) the Pigeonhole Principle

The Pigeonhole Principle says that if a set of mn + 1 or more items is divided into n groups, at least one group has at least m + 1 items.

• (b) an odd number

An odd number is an integer that can be written as 2k + 1, where k is another integer.

• (c) the Division Theorem

The Division Theorem says that if n is an integer and m a positive integer, there exist integers q and r such that n = qm + r and 0 ≤ r < m.

• (d) the mod operation

The mod operation, written "n mod m" in the textbook but (mostly) written "n % m" in Java, returns the number r from the Division Theorem above. It returns the remainder when n is divided by m. (When n is negative, the textbook's mod operation returns r such that 0 ≤ r < m, while Java's % operation returns a negative number.)

• (e) a perfect square

A perfect square is an integer that can be written as k2 for some integer k.

• Question 2 (15): Identify each of the following statements as true or false. No explanation is needed or wanted, and there is no penalty for guessing. (3 points each)

• (a) The binary representation of the decimal number 36 is 100010.

FALSE. The correct binary for 36 is 100100.

• (b) If S is a set of eleven different positive integers, there exist two elements x and y of S, with x ≠ y, such that x and y have the same last digit in decimal notation.

TRUE. If we divide the 11 numbers into 10 groups based on their last digit, the Pigeonhole Principle says that at least one group must have at least two elements.

• (c) The sum of any two rational numbers is rational.

TRUE. If x and y are arbitrary rational numbers, then they can be written as x = a/b and y = c/d, where a and c are integers and b and d are nonzero integers. Then x + y = (ad + bc)/bd, which is an integer divided by a nonzero integer and thus a rational number.

• (d) Every number that is divisible by 6 is also divisible by 12.

FALSE. The number 6 is divisible by 6 but not by 12. The converse of this statement is true.

• (e) If n is an odd number, then (n-3)3 + 6 must be an even number.

TRUE. If n is odd, then n - 3 is even, its square is also even, and we get another even number when we add the even number 6 to it.

• Question 3 (20): Prove that if an integer n is not divisible by 4, then n3 is also not divisible by 4. (Hint: Use Proof by Cases and the Division Theorem on n, with m = 4.)

Following the hint, we write n as 4q + r and consider the four cases for the four possible values of r.

• If n = 4q, it is divisible by 4 and we have nothing to prove.

• If n = 4q + 1, n3 + 2 = 64q3 + 48q2 + 12q + 3, which is not divisible by 4.

• If n = 4q + 2, n3 + 2 = 64q3 + 96q2 + 48q + 10, which is not divisible by 4.

• If n = 4q + 3, n3 + 2 = 64q3 + 144q2 + 108q + 29, which is not divisible by 4.

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

Our P(n) is the statement "an = n3 + 2".

Our base case P(1) = "a1 = 13 + 2", which is true because a1 is defined to be 3 and the right-hand side evaluates to 3.

For the inductive step, we assume an-1 = (n-1)2 + 2 and try to prove that an = n3 + 2.

Using the rule for the sequence, an is equal to an-1 + 3n2 - 3n + 1 which is equal to (n-1)3 + 2 + 3n2 - 3n + 1. Expanding the first term, this is n3 - 3n2 + 3n - 1 + 2 + 3n2 - 3n + 1, which simplifies to n3 + 2.

We have completed the base case and the inductive step, and thus proved that P(n) is true for all positive integers n.

• Question 5 (25): The Tribonacci sequence is defined by the rules T1 = 1, T2 = 1, T3 = 1, and for all n with n > 3, Tn = Tn-1 + Tn-2 + Tn-3.

• (a, 5) Compute Tk for all k such that 1 ≤ k ≤ 7.

T1, T2, and T3 are all 1 as given. T4 = 1 + 1 + 1 = 3, T5 = 1 + 1 + 3 = 5, T6 = 1 + 3 + 5 = 9, and T7 = 3 + 5 + 9 = 17.

• (b, 20) Prove by induction that for all positive integers n, T(n) is odd. You will need separate base cases for n = 1, n = 2, and n = 3.

Our statement P(n) is "Tn is odd".

For the three base cases, we just need to observe that T1, T2, and T3 are each odd numbers since they are each 1.

For the inductive case, we assume that P(i) is true for all i with 1 ≤ i ≤ n - 1 and use that assumption to prove P(n).

If n > 3, then n - 1, n - 2, and n - 3 are each positive integers and we may assume that Tn-1, Tn-2, and Tn-3 are each odd numbers. If we write them as 2a + 1, 2b + 1, and 2c + 1 respectively, we can see that Tn = 2(a + b + c) + 3 and is thus an odd number itself.

Some people said that each of the three odd numbers was equal to the same number 2k + 1, whereas all we may assume about them is that each is odd.

One person had an interesting alternate approach, expanding Tn-1 to get that Tn = (T2 + T3 + T4) + T2 + T3, which is 2(T2 + T3) + T4 and thus a multiple of two plus a number assumed to be odd, and hence an odd number. This is a correct proof except for one problem. It asssumes that Tn-4 is odd, which we only know if n - 4 is a positive integer, which is only true for n ≥ 5. Since we have only assumed that n ≥ 4, to use this approach we have to deal with the case of n = 4 separately, referring to part (a) and observing that 3 is odd.