Discrete Mathematics lecture notes 101
November 11, 2013
27. Some applications of InclusionExclusions
Last time we saw that for a collection of finite sets
A
1
, A
2
, . . . , A
n
, we could compute the size of the
union if we knew the size of each
A
i
individually along with the sizes of all intersections:
n
[
i
=1
A
i
=
n
X
i
=1

A
i
 
X
1
≤
i<j
≤
n

A
i
∩
A
j

+
X
1
≤
i<j<k
≤
n

A
i
∩
A
j
∩
A
k
 
. . .
+ (

1)
n

1
n
\
i
=1
A
i
.
Let’s use this to make a couple of interesting computations.
Euler’s totient function.
Euler’s totient function
φ
:
N
≥
0
→
N
is defined by
φ
(
n
) =
{
1
≤
i
≤
n

(
i, n
) = 1
}
,
i.e.,
φ
(
n
) is the number of numbers less than
n
that are relatively prime to
n
.
φ
has a number of interesting
algebraic properties; for now let’s just come up with a closedform formula for
φ
(
n
).
Let [
n
] be the set
{
1
,
2
, . . . , n
}
.
φ
(
n
) can be described the size of the set
D
:=
{
i
∈
[
n
]

(
i, n
)

1
}
.
Instead of computing the size of this set directly, let’s compute the size of the
complement
of
D
in [
n
]:
C
= [
n
]
\
D
=
{
j
∈
[
n
]

(
j, n
)
6
= 1
}
. Clearly

C

+

D

=

[
n
]

=
n
, so determining

C

will give us

D

via the
formula

D

=
n
 
C

.
For fixed
n
, let
p
1
, . . . , p
‘
be the distinct primes that divide
n
.
1
If
j
∈
C
, then (
j, n
)
6
= 1, so in particular
there must be some
p
k
such that
p
k

j
.
2
Thus, for
k
= 1
,
2
, . . . , ‘
, defining
C
k
:=
{
j
∈
[
n
]

p
k

j
}
, it follows
that
C
=
‘
S
k
=1
C
k
, and we can hope to make use of InclusionExclusion. We’ll make use of a small technical
lemma.
Lemma 1.
For
n
∈
N
≥
1
and
d
∈ 
N
a divisor of
n
, there are
n
d
multiples of
d
that live in
[
n
]
.
Proof.
There is precisely one element of [
d
] =
{
1
,
2
, . . . , d
}
that is a multiple of
d
(namely
d
itself).
As
d

n
6
= 0, we have
d
≤
n
and hence [
d
]
⊆
[
n
] contains exactly one element of [
n
] that is a multiple of
d
. For
each
j
∈ {
1
,
2
, . . . ,
n
d
}
, let
di
+ [
d
] be the set
{
di
+ 1
, di
+ 2
, . . . , di
+
d
}
: We obtain
di
+ [
d
] from [
d
] by