Mike Slackenerny August 21, 2019 6.046 Problem Set 0 Solutions Collaborators: Cecilia, Tajel Problem 0-1. Pseudocode Describe an algorithm to multiply two positive integers. Solution: Multiply(m, n) 1 A=0 2 for i = 1 to m 3 do B = 0 4 for j = 1 to n 5 do B = B + 1 6 A=A+B 7 return P Note: We added the “clrscode” package to Line 10. Problem 0-2. Equations Prove the following identities. (a) 1 = −1. Solution: 1= √ 1= p √ √ (−1)(−1) = −1 −1 = −1. (b) 0 = 1. Solution: 0 = = = = = 0 + 0 + 0 + ... (1 − 1) + (1 − 1) + (1 − 1) + . . . 1 + (−1 + 1) + (−1 + 1) + (−1 + 1) + . . . 1 + 0 + 0 + 0 + ... 1, where Equation (??) follows from the associative law. 1 (1) (2) (3) (4) (5) (c) 2 = 1. Solution: Let a and b be equal positive integers. We have a=b ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ a2 = ab a2 − b2 = ab − b2 (a + b)(a − b) = b(a − b) a+b=b b+b=b 2b = b 2 = 1. 2