Integer Solutions
-For lower values of c, all integer solutions have the property that either x or y or both are
negative. However for higher c, there are integer solutions where both x and y are nonnegative. For example, 4x + 9y = 60 has the solution (x
Your Name:
Harvard University
Computer Science 20
Midterm 1
Monday, February 22, 2016
PROBLEM 1
Prove that if you pick 5 distinct integers from cfw_1, . . . , 100, some two differ by at most 24.
Solution.
1
PROBLEM 2
Let A = p q and B = p q. Show by writi
Computer Science 20, Midterm, 2/21/14
Four problems, all count equally.
1. Rewrite the following expressions using exactly one operation. For example,
the answer for (p q) would be p q. T and F represent boolean true
and false. Allowable operators are , ,
% Document class for CS121 documents
% Much of this file was stolen from psinclude.tex, which included
%
LaTeX code writen by Bob Walton and Craig Silverstein, and edited
%
at various times by Adam Deaton and Ben Wildasin. This document
%
class is origina
% Please fill in your name and collaboration statement here.
\newcommandcfw_\studentNamecfw_*FILL IN YOUR NAME HERE*
\newcommandcfw_\collaborationStatementcfw_*FILL IN YOUR COLLABORATION STATEMENT HERE
\ (See the syllabus for information)*
%
\documentclas
Exercise Solutions
Chapter 1 Introduction to Sets and Functions: 1.3.1: Which of the following sets are equal to the set of all integers that are multiples of 5.
There may be more than one or none.
(1) cfw_5n|n 2 R
(2) cfw_5n|n 2 Z
(3) cfw_n 2 Z|n = 5k an
Bezout
-Question: Do you see any integer solution for 10x + 15y = 1?
Question: How about 10x + 15y = 2? Whats the problem?
Answer: Seems like the only hope is if c is some multiple of 5.
Question: Whats special about 5?
Answer: 5 = gcd(10, 15).
-Let a, b,
Diophantine Examples
-Find the non-negative integer solutions of 10x + 15y = 100.
We know that the full set of integer solutions is:
cfw_(x = 20 + 3k, y = 20 2k) | k Z
We need to restrict ourselves to k such that
20 + 3k 0
20 2k 0
These are equivalent to:
Greatest Common Divisor
-Imagine you have a floor of size 1053 inches by 481 inches. You would like to tile
your floor with square tiles. You can of course use 1 inch by 1 inch tiles, but you would
like to use as few square tiles as possible. No partial t
Bezout's Identity
-Let a, b, c Z, where d = gcd(a, b) and c
is a multiple of d. Suppose that (x = x0, y = y0) is one particular integer solution to
ax + by = c.
-Then the complete set of integer solutions is
S = cfw_x = x0 + k b/d, y = y0 k a/d
kZ
Proof:
Division Theorem
-If a, b Z, with a 6= 0, we say that a divides b, written a|b, if q Z, such
that b = aq. We say that a is a divisor or factor of b.
-Let a, b, c Z, where a 6= 0 and b 6= 0. Then:
-If a|b and b|c, then a|c.
-If a|b and a|c, then a|(bx + cy
Diophantine Equations
-Imagine that your favorite restaurant is McDonalds, and your favorite food is chicken
nuggets.
It turns out that chicken nuggets come in two different sizes: the 4-box and the 9-box.
Youre
having your friends for dinner. Fortunately
Sylvester's Theorem
-Let a and b be positive, relatively prime
integers and c be a positive integer. Then there exist non-negative integers, x and y, that
satisfy
ax + by = c,
if
c > ab a b .
When c = ab a b, there are no non-negative integer solutions.
P
Euclidean Algorithm
-Suppose we want to find integers x and y such that 89x + 33y = 1.
To find x and y, we will need to first apply the Euclidean algorithm. This seems
extraneous,
since we already know that gcd(89, 33) = 1. However well need to do this, s
Properties of Euclidean Algorithm
-To solve the Chicken McNugget problem, it will help to first realize that there are actually
an infinite number of different pairs, (x, y), of integer solutions to an equation of the form
ax + by = c,
when a and b are re
SHOULD I TAKE CS 20?
This quiz is meant to help you decide whether to take CS 20. If the terminology and questions are
unfamiliar to you, or if they are vaguely familiar but you cant actually do the problems, you should take
CS 20 before taking CS 121 or