Q1 [20 points] Q2 [20 points]

BU-CmpE 220 Discrete Mathematics
bingol/Fall 2011
Midterm 2, 110 minutes
Dec 06, 2011
Read me. Number pages consequently. Answer n should go to page n. “Textbook” or “Grimaldi5e” means
Grimaldi 5th edition. Be clear, precise, short, necessary and sufficient in your answers. Otherwise prepare to
lose points.
Show your own work. Open (i) textbook, (ii) course handouts and (iii) your own handwritten notes, only. No
photocopied material. No printouts of any kind. No questions. No exchange of information, books, notes, pencils
etc. No phones. Keep the question sheet. Good luck.
Q1 [20 points]
Let composite number a ∈ N be given as a = pn1 1 pn2 2 pn3 3 where p1 , p2 , p3 are prime and n1 , n2 , n3 are
positive integers. How many positive divisors does a have? Justify your answer.
Solution.
Let b ∈ N a positive divisors of a, that is, a = qb where q ∈ N. Then b = pk11 pk22 pk33 where 0 ≤ k1 ≤ n1 ,
0 ≤ k2 ≤ n2 , and 0 ≤ k3 ≤ n3 . Any such k1 , k2 , k3 combination corresponds to a positive divisor. Then
the number of positive divisors is equal to the number of different combinations of such k1 , k2 , k3 which
is (k1 + 1)(k2 + 1)(k3 + 1).
Q2 [20 points]
How many different n–digit numbers are there in which the digits are in non-decreasing order when
they are read from left to right where n is a positive integer? (For example, for n = 2 you should include
77, 58, 16, but not 53, 01 or 00) Justify your answer.
Solution.
Such a number is of the form:
11...11
| {z } |33...33
{z } |44...44
{z } |55...55
{z } 66...66
| {z } 77...77
| {z } 88...88
| {z } 99...9
| {z }
| {z } 22...22
n1
n2
n3
n4
n5
n6
n7
n8
n9
where ni denotes the number of the digit i inPthe n–digit number 1 ≤ i ≤ 9 with the restriction that
9
the total number of digits should be n. i.e.
i=1 ni = n. Since an n–digit number can not have 0’s
at its left end and the digits are in non-decreasing order such a number can not contain any 0’s except
for the number 0. Note that for specific values of n1 , ..., n9 there is only one number that satisfies the
non-decreasing condition. Therefore, there is no need to consider the permutations.
Hence, counting such numbers reduces to finding the number of integer solutions of the equation
n1 + n2 + .... + n9 = n where ni ≥ 1
which equals to
n+9−1
n+8
=
9−1
8
∀i = 1, .., 9
∀n ≥ 2
∀n ≥ 2
n = 1 is an exception to the above formula since it doesn’t account for 0. The result is
1+8
+ 1 = 9 + 1 = 10
for n = 2
8
1
(1)
Q3 [20 points]
Suppose that S is a set with n elements. How many ordered pairs (A, B) are there such that A and
B are subsets of S with A ⊆ B? [Hint: Show that each element of S belongs to A, B r A, or S r B.]
Justify your answer.
Solution.
Let A and B subsets of S with A ⊆ B.
∀s ∈ S [s ∈ S]
tautology
⇔∀s ∈ S [(s ∈ B) ⊕ (s ∈ S − B)]
since B ⊆ S ⇒ S = B ∪ (S − B)
⇔∀s ∈ S [((s ∈ A) ⊕ (s ∈ B − A)) ⊕ (s ∈ S − B)]
since A ⊆ B ⇒ B = A ∪ (B − A)
and B ∩ (S − B) = ∅
and A ∩ (B − A) = ∅
Hence, for every s ∈ S there are three mutually disjoint alternatives: s either belongs to A or B r A,
or S r B. Since the choice for different elements are independent from each other (i.e. can be done
concurrently), the result can be found by rule of product. Number of ordered pairs is
..... · 3} = 3n
|3 · 3 ·{z
n times
Q4 [20 points]
Prove or disprove the following.
a) If p is prime, prove that p divides kp , for all 0 < k < p.
b) If a, b ∈ Z, prove that (a + b)p ≡ ap + bp (mod p).
Solution.
a) By defn of combinations we know that kp is an integer.
p
p!
=
k
k! · (p − k)!
p · (p − 1)...(p − k + 1) · (p
−
k)!
=
k! · (p
−
k)!
p · (p − 1)...(p − k + 1)
=
k!
(p − 1)...(p − k + 1)
=p·
k!
p
defn of
k
Note that gcd(k!, p) = 1. Because gcd(k!, p) = d > 1 implies that d|p which contradicts to the fact
that p is prime.
(p − 1)...(p − k + 1)
∈Z
k!
⇒ k! | (p − 1)...(p − k + 1)
p
⇒
=p·x∈Z
k
p
⇒p|
k
gcd(k!, p) = 1 and p ·
thm. in handouts: a | bc ∧ gcd(a, b)=1 ⇒ a | c
where x =
2
(p − 1)...(p − k + 1)
k!
b)
p p−1
p p−k k
p
(a + b) = a +
a b + ... +
a
b + ... +
abp−1 + bp
1
k
p−1
p
p
Binomial theorem
⇒
p p−1
p p−k k
p
(a + b) ≡ a +
a b + ... +
a
b + ... +
abp−1 + bp
(mod p)
1
k
p−1
0 (mod n)
0 (mod n)
0 (mod p)
>
7
7
p p−1
p p−k k
p
p
p
p
p−1
p
(a + b) ≡ a + a b + ... + a
b + ... + ab
+b
(mod n)
≡0
1
k
p
−
1
k
p
p
≡ a p + bp
(mod p) by (a)
(mod p)
Q5 [20 points]
Show that in any set of n + 1 positive integers not exceeding 2n there must be two that are relatively
prime.
Solution.
Let S = {1, 2, ...2n}. We have to prove that any subset A of S with n + 1 elements must contain two
elements that are relatively prime. Let A be a subset of S with n + 1 elements.
If we group the members of S into pairs of consecutive numbers in the following manner:
S = { 1, 2 , 3, 4 , .... a, a + 1 .... 2n − 1, 2n}
|{z} |{z}
| {z } | {z }
1
2
n
There are n such pairs. If we think of these n pairs as boxes and the n + 1 elements as pigeons, from
pigeon-hole principle it follows that one of these boxes should contain two pigeons. This means that A
should contain two elements from one of these boxes, i.e. two consecutive numbers, say a and a + 1.
Claim: gcd(a, a + 1) = 1
Let d =gcd(a, a + 1).
⇒d | a ∧ d | (a + 1)
since d = gcd(a, a + 1)
⇒d | a − (a + 1)
⇒d | 1
⇒d = 1
Hence A contains two elements that are relatively prime.
Quotation of the exam: Leopold Kronecker (1823 – 1891)
God made the integers, all the rest is the work of man.
Source: Grimaldi, Discrete and Combinatorial Mathematics
3