Docsity

Combinatorics and the Pascal Triangle: Exploring Subsets, Permutations, and Trees, Lecture notes of Discrete Mathematics

Partial preview of the text

Download Combinatorics and the Pascal Triangle: Exploring Subsets, Permutations, and Trees and more Lecture notes Discrete Mathematics in PDF only on Docsity!

Discrete Mathematics

Lecture Notes, Yale University, Spring 1999

L. Lov´asz and K. Vesztergombi

Parts of these lecture notes are based on L. Lov´asz – J. Pelik´an – K. Vesztergombi: Kombinatorika (Tank¨onyvkiad´o, Budapest, 1972); Chapter 14 is based on a section in L. Lov´asz – M.D. Plummer: Matching theory (Elsevier, Amsterdam, 1979)

  • 1 Introduction
  • 2 Let us count!
    • 2.1 A party
    • 2.2 Sets and the like
    • 2.3 The number of subsets
    • 2.4 Sequences
    • 2.5 Permutations
  • 3 Induction
    • 3.1 The sum of odd numbers
    • 3.2 Subset counting revisited
    • 3.3 Counting regions
  • 4 Counting subsets
    • 4.1 The number of ordered subsets
    • 4.2 The number of subsets of a given size
    • 4.3 The Binomial Theorem
    • 4.4 Distributing presents
    • 4.5 Anagrams
    • 4.6 Distributing money
  • 5 Pascal’s Triangle
    • 5.1 Identities in the Pascal Triangle
    • 5.2 A bird’s eye view at the Pascal Triangle
  • 6 Fibonacci numbers
    • 6.1 Fibonacci’s exercise
    • 6.2 Lots of identities
    • 6.3 A formula for the Fibonacci numbers
  • 7 Combinatorial probability
    • 7.1 Events and probabilities
    • 7.2 Independent repetition of an experiment
    • 7.3 The Law of Large Numbers
  • 8 Integers, divisors, and primes
    • 8.1 Divisibility of integers
    • 8.2 Primes and their history
    • 8.3 Factorization into primes
    • 8.4 On the set of primes
    • 8.5 Fermat’s “Little” Theorem
    • 8.6 The Euclidean Algorithm
    • 8.7 Testing for primality
  • 9 Graphs
    • 9.1 Even and odd degrees
    • 9.2 Paths, cycles, and connectivity
  • 10 Trees
    • 10.1 How to grow a tree?
    • 10.2 Rooted trees
    • 10.3 How many trees are there?
    • 10.4 How to store a tree?
  • 11 Finding the optimum
    • 11.1 Finding the best tree
    • 11.2 Traveling Salesman
  • 12 Matchings in graphs
    • 12.1 A dancing problem
    • 12.2 Another matching problem
    • 12.3 The main theorem
    • 12.4 How to find a perfect matching?
    • 12.5 Hamiltonian cycles
  • 13 Graph coloring
    • 13.1 Coloring regions: an easy case
  • 14 A Connecticut class in King Arthur’s court
  • 15 A glimpse of cryptography
    • 15.1 Classical cryptography
  • 16 One-time pads
    • 16.1 How to save the last move in chess?
    • 16.2 How to verify a password—without learning it?
    • 16.3 How to find these primes?
    • 16.4 Public key cryptography

1 Introduction

For most students, the first and often only area of mathematics in college is calculus. And it is true that calculus is the single most important field of mathematics, whose emergence in the 17th century signalled the birth of modern mathematics and was the key to the successful applications of mathematics in the sciences. But calculus (or analysis) is also very technical. It takes a lot of work even to introduce its fundamental notions like continuity or derivatives (after all, it took 2 centuries just to define these notions properly). To get a feeling for the power of its methods, say by describing one of its important applications in detail, takes years of study. If you want to become a mathematician, computer scientist, or engineer, this investment is necessary. But if your goal is to develop a feeling for what mathematics is all about, where is it that mathematical methods can be helpful, and what kind of questions do mathematicians work on, you may want to look for the answer in some other fields of mathematics. There are many success stories of applied mathematics outside calculus. A recent hot topic is mathematical cryptography, which is based on number theory (the study of positive integers 1, 2 , 3 ,.. .), and is widely applied, among others, in computer security and electronic banking. Other important areas in applied mathematics include linear programming, coding theory, theory of computing. The mathematics in these applications is collectively called discrete mathematics. (“Discrete” here is used as the opposite of “continuous”; it is also often used in the more restrictive sense of “finite”.) The aim of this book is not to cover “discrete mathematics” in depth (it should be clear from the description above that such a task would be ill-defined and impossible anyway). Rather, we discuss a number of selected results and methods, mostly from the areas of combinatorics, graph theory, and combinatorial geometry, with a little elementary number theory. At the same time, it is important to realize that mathematics cannot be done without proofs. Merely stating the facts, without saying something about why these facts are valid, would be terribly far from the spirit of mathematics and would make it impossible to give any idea about how it works. Thus, wherever possible, we’ll give the proofs of the theorems we state. Sometimes this is not possible; quite simple, elementary facts can be extremely difficult to prove, and some such proofs may take advanced courses to go through. In these cases, we’ll state at least that the proof is highly technical and goes beyond the scope of this book. Another important ingredient of mathematics is problem solving. You won’t be able to learn any mathematics without dirtying your hands and trying out the ideas you learn about in the solution of problems. To some, this may sound frightening, but in fact most people pursue this type of activity almost every day: everybody who plays a game of chess, or solves a puzzle, is solving discrete mathematical problems. The reader is strongly advised to answer the questions posed in the text and to go through the problems at the end of each chapter of this book. Treat it as puzzle solving, and if you find some idea that you come up with in the solution to play some role later, be satisfied that you are beginning to get the essence of how mathematics develops. We hope that we can illustrate that mathematics is a building, where results are built

2 Let us count!

2.1 A party

Alice invites six guests to her birthday party: Bob, Carl, Diane, Eve, Frank and George. When they arrive, they shake hands with each other (strange European custom). This group is strange anyway, because one of them asks: “How many handshakes does this mean?” “I shook 6 hands altogether” says Bob, “and I guess, so did everybody else.” “Since there are seven of us, this should mean 7 · 6 = 42 handshakes” ventures Carl. “This seems too many” says Diane. “The same logic gives 2 handshakes if two persons meet, which is clearly wrong.” “This is exactly the point: every handshake was counted twice. We have to divide 42 by 2, to get the right number: 21.” settles Eve the issue.

When they go to the table, Alice suggests: “Let’s change the seating every half an hour, until we get every seating.” “But you stay at the head of the table” says George, “since you have your birthday.” How long is this party going to last? How many different seatings are there (with Alice’s place fixed)? Let us fill the seats one by one, starting with the chair on Alice’s right. We can put here any of the 6 guests. Now look at the second chair. If Bob sits on the first chair, we can put here any of the remaining 5 guests; if Carl sits there, we again have 5 choices, etc. So the number of ways to fill the first two chairs is 5 + 5 + 5 + 5 + 5 + 5 = 6 · 5 = 30. Similarly, no matter how we fill the first two chairs, we have 4 choices for the third chair, which gives 6 · 5 · 4 ways to fill the first three chairs. Going on similarly, we find that the number of ways to seat the guests is 6 · 5 · 4 · 3 · 2 · 1 = 720. If they change seats every half an hour, it takes 360 hours, that is, 15 days to go through all seating orders. Quite a party, at least as the duration goes!

2.1 How many ways can these people be seated at the table, if Alice too can sit any- where?

After the cake, the crowd wants to dance (boys with girls, remember, this is a conser- vative European party). How many possible pairs can be formed? OK, this is easy: there are 3 girls, and each can choose one of 4 guys, this makes 3 · 4 = 12 possible pairs.

After about ten days, they really need some new ideas to keep the party going. Frank has one: “Let’s pool our resources and win a lot on the lottery! All we have to do is to buy enough tickets so that no matter what they draw, we should have a ticket with the right numbers. How many tickets do we need for this?” (In the lottery they are talking about, 5 numbers are selected from 90.) “This is like the seating” says George, “Suppose we fill out the tickets so that Alice marks a number, then she passes the ticket to Bob, who marks a number and passes it to Carl,... Alice has 90 choices, no matter what she chooses, Bob has 89 choices, so there are

90 · 89 choices for the first two numbers, and going on similarly, we get 90 · 89 · 88 · 87 · 86 possible choices for the five numbers.” “Actually, I think this is more like the handshake question” says Alice. “If we fill out the tickets the way you suggested, we get the same ticket more then once. For example, there will be a ticket where I mark 7 and Bob marks 23, and another one where I mark 23 and Bob marks 7.” Carl jumped up: “Well, let’s imagine a ticket, say, with numbers 7, 23 , 31 , 34 and 55. How many ways do we get it? Alice could have marked any of them; no matter which one it was that she marked, Bob could have marked any of the remaining four. Now this is really like the seating problem. We get every ticket 5 · 4 · 3 · 2 · 1 times.” “So” concludes Diane, “if we fill out the tickets the way George proposed, then among the 90 · 89 · 88 · 87 · 86 tickets we get, every 5-tuple occurs not only once, but 5 · 4 · 3 · 2 · 1 times. So the number of different tickets is only

90 · 89 · 88 · 87 · 86 5 · 4 · 3 · 2 · 1

We only need to buy this number of tickets.” Somebody with a good pocket calculator computed this value in a glance; it was 43,949,268. So they had to decide (remember, this happens in a poor European coun- try) that they don’t have enough money to buy so many tickets. (Besides, they would win much less. And to fill out so many tickets would spoil the party.. .)

So they decide to play cards instead. Alice, Bob, Carl and Diane play bridge. Looking at his cards, Carl says: “I think I had the same hand last time.” “This is very unlikely” says Diane. How unlikely is it? In other words, how many different hands can you have in bridge? (The deck has 52 cards, each player gets 13.) I hope you have noticed it: this is essentially the same question as the lottery. Imagine that Carl picks up his cards one by one. The first card can be any one of the 52 cards; whatever he picked up first, there are 51 possibilities for the second card, so there are 52 · 51 possibilities for the first two cards. Arguing similarly, we see that there are 52 · 51 · 50 ·... · 40 possibilities for the 13 cards. But now every hand was counted many times. In fact, if Eve comes to quibbiz and looks into Carl’s cards after he arranged them, and tries to guess (I don’t now why) the order in which he picked them up, she could think: “He could have picked up any of the 13 cards first; he could have picked up any of the remaining 12 cards second; any of the remaining 11 cards third;... Aha, this is again like the seating: there are 13 · 12 ·... · 2 · 1 orders in which he could have picked up his cards.” But this means that the number of different hands in bridge is 52 · 51 · 50 ·... · 40 13 · 12 ·... · 2 · 1

So the chance that Carl had the same hand twice in a row is one in 635,013,559,600, very small indeed.

Finally, the six guests decide to play chess. Alice, who just wants to watch them, sets up 3 boards.

We may specify a set by listing its elements between braces; so

P = {Alice, Bob, Carl, Diane, Eve, Frank, George}

is the set of participants of Alice’s birthday party, or

{ 12 , 23 , 27 , 33 , 67 }

is the set of numbers on my uncle’s lottery ticket. Sometimes we replace the list by a verbal description, like {Alice and her guests}.

Often we specify a set by a property that singles out the elements from a large universe like real numbers. We then write this property inside the braces, but after a colon. Thus

{x ∈ Z : x ≥ 0 }

is the set of non-negative integers (which we have called Z+ before), and

{x ∈ P : x is a girl} = {Alice, Diane, Eve}

(we denote this set by G). Let me also tell you that

D = {x ∈ P : x is over 21} = {Alice, Carl, Frank}

(we denote this set by D). A set A is called a subset of a set B, if every element of A is also an element of B. In other words, A consists of certain elements of B. We allow that A consists of all elements of B (in which case A = B), or none of them (in which case A = ∅). So the empty set is a subset of every set. The relation that A is a subset of B is denoted by

A ⊆ B.

For example, among the various sets of people considered above, G ⊆ P and D ⊆ P. Among the sets of numbers, we have a long chain:

∅ ⊆ N ⊆ Z+ ⊆ Z ⊆ Q ⊆ R

The intersection of two sets is the set consisting of those elements that elements of both sets. The intersection of two sets A and B is denoted by A ∩ B. For example, we have G ∩ D = {Alice}. Two sets whose intersection is the empty set (in other words, have no element in common) are called disjoint.

2.3 Name sets whose elements are (a) buildings, (b) people, (c) students, (d) trees, (e) numbers, (f) points. 2.4 What are the elements of the following sets: (a) army, (b) mankind, (c) library, (d) the animal kingdom?

the cardinalities of Z and R. This is the subject matter of set theory and does not concern us here.

2.5 Name sets having cardinality (a) 52, (b) 13, (c) 32, (d) 100, (e) 90, (f) 2,000,000.

2.6 What are the elements of the following (admittedly peculiar) set: {Alice, { 1 }}?

2.7 We have not written up all subset relations between various sets of numbers; for example, Z ⊆ R is also true. How many such relations can you find between the sets ∅, N, Z+, Z, Q, R?

2.8 Is an “element of a set” a special case of a “subset of a set”?

2.9 List all subsets of { 0 , 1 , 3 }. How many do you get?

2.10 Define at least three sets, of which {Alice, Diane, Eve} is a subset.

2.11 List all subsets of {a, b, c, d, e}, containing a but not containing b.

2.12 Define a set, of which both { 1 , 3 , 4 } and { 0 , 3 , 5 } are subsets. Find such a set with a smallest possible number of elements.

2.13 (a) Which set would you call the union of {a, b, c}, {a, b, d} and {b, c, d, e}? (b) Find the union of the first two sets, and then the union of this with the third. Also, find the union of the last two sets, and then the union of this with the first set. Try to formulate what you observed. (c) Give a definition of the union of more than two sets.

2.14 Explain the connection beween the notion of the union of sets and exercise 2.2.

2.15 We form the union of a set with 5 elements and a set with 9 elements. Which of the following numbers can we get as the cardinality of the union: 4, 6, 9, 10, 14, 20?

2.16 We form the union of two sets. We know that one of them has n elements and the other has m elements. What can we infer for the cardinality of the union?

2.17 What is the intersection of (a) the sets { 0 , 1 , 3 } and { 1 , 2 , 3 }; (b) the set of girls in this class and the set of boys in this class; (c) the set of prime numbers and the set of even numbers?

2.18 We form the intersection of two sets. We know that one of them has n elements and the other has m elements. What can we infer for the cardinality of the intersection?

2.19 Prove that |A ∪ B| + |A ∩ B| = |A| + |B|.

2.20 The symmetric difference of two sets A and B is the set of elements that belong to exectly one of A and B.

(a) What is the symmetric difference of the set Z+ of non-negative integers and the set E of even integers (E = {... − 4 , − 2 , 0 , 2 , 4 ,... contains both negative and positive even integers).

(b) Form the symmetric difference of A ad B, to get a set C. Form the symmetric difference of A and C. What did you get? Give a proof of the answer.

abc ab ac a bc b c -

b S

a S

b

c S c S c S c S

S

ε

Y N

Y N Y N

Y N Y N Y N Y N

ε ε

ε ε ε ε

Figure 1: A decision tree for selecting a subset of {a, b, c}.

Since the number of nodes doubles from level to level as we go down, the last level contains 23 = 8 nodes (and if we had an n-element set, it would contain 2n^ nodes).

Remark. A picture like this is called a tree. (This is not a mathematical definition, which we’ll see later.) If you want to know why is the tree growing upside down, ask the computer scientists who introduced it, not us.

We can give another proof of theorem 2.1. Again, the answer will be made clear by asking a question about subsets. But now we don’t want to select a subset; what we want is to enumerate subsets, which means that we want to label them with numbers 0, 1 , 2 ,... so that we can speak, say, about subset No. 23 of the set. In other words, we want to arrange the subsets of the set in a list and the speak about the 23rd subset on the list. (We actually want to call the first subset of the list No. 0, the second subset on the list No. 1 etc. This is a little strange but this time it is the logicians who are to blame. In fact, you will find this quite natural and handy after a while.) There are many ways to order the subsets of a set to form a list. A fairly natural thing to do is to start with ∅, then list all subsets with 1 elements, then list all subsets with 2 elements, etc. This is the way the list (1) is put together. We could order the subsets as in a phone book. This method will be more transparent if we write the subsets without braces and commas. For the subsets of {a, b, c}, we get the list ∅, a, ab, abc, ac, b, bc, c. These are indeed useful and natural ways of listing all subsets. They have one short- coming though. Imagine the list of the subsets of five elements, and ask yourself to name the 23rd subset on the list, without actually writing down the whole list. This will be difficult! Is there a way to make this easier? Let us start with another way of denoting subsets (another encoding in the mathematical jargon). We illustrate it on the subsets of {a, b, c}. We look at the elements one by one, and write down a 1 if the element occurs in the subset and a 0 if it does not. Thus for

the subset {a, c}, we write down 101, since a is in the subset, b is not, and c is in it again. This way every subset in “encoded” by a string of length 3, consisting of 0’s and 1’s. If we specify any such string, we can easily read off the subset it corresponds to. For example, the string 010 corresponds to the subset {b}, since the first 0 tells us that a is not in the subset, the 1 that follows tells us that b is in there, and the last 0 tells us that c is not there. Now such strings consisting of 0’s and 1’s remind us of the binary representation of integers (in other words, representations in base 2). Let us recall the binary form of non- negative integers up to 10:

0 = (^02) 1 = (^12) 2 = (^102) 3 = 2 + 1 = 11 2 4 = (^1002) 5 = 4 + 1 = 101 2 6 = 4 + 2 = 110 2 7 = 4 + 2 + 1 = 111 2 8 = (^10002) 9 = 8 + 1 = 1001 2 10 = 8 + 2 = 1010 2

(We put the subscript 2 there to remind ourselves that we are working in base 2, not 10.) Now the binary forms of integers 0, 1 ,... , 7 look almost as the “codes” of subsets; the difference is that the binary form of an integer always starts with a 1, and the first 4 of these integers have binary forms shorter than 3, while all codes of subsets consist of exactly 3 digits. We can make this difference disappear if we append 0’s to the binary forms at their beginning, to make them all have the same length. This way we get the following correspondence: 0 ⇔ 02 ⇔ 000 ⇔ ∅ 1 ⇔ 12 ⇔ 001 ⇔ {c} 2 ⇔ 102 ⇔ 010 ⇔ {b} 3 ⇔ 112 ⇔ 011 ⇔ {b, c} 4 ⇔ 1002 ⇔ 100 ⇔ {a} 5 ⇔ 1012 ⇔ 101 ⇔ {a, c} 6 ⇔ 1102 ⇔ 110 ⇔ {a, b} 7 ⇔ 1112 ⇔ 111 ⇔ {a, b, c}

So we see that the subsets of {a, b, c} correspond to the numbers 0, 1 ,... , 7. What happens if we consider, more generally, subsets of a set with n elements? We can argue just like above, to get that the subsets of an n-element set correspond to integers, starting with 0, and ending with the largest integer that has only n digits in its binary representation (digits in the binary representation are usually called bits). Now the smallest number with n + 1 bits is 2n, so the subsets correspond to numbers 0, 1 , 2 ,... , 2 n^ − 1. It is clear that the number of these numbers in 2n, hence the number of subsets is 2n.

which means that k − 1 is the largest integer not exceeding x. Mathematicians have a name for this: it is the integer part or floor of x, and it is denoted by ⌊x⌋. We can also say that we obtain k by rounding x down to the next integer. There is also a name for the number obtained by rounding x up to the next integer: it is called the ceiling of x, and denoted by ⌈x⌉. Using any scientific calculator (or table of logarithms), we see that lg 2 ≈ 0 .30103, thus 100 lg 2 ≈ 30 .103, and rounding this down we get that k − 1 = 30. Thus 2^100 has 31 digits.

2.21 Under the correspondence between numbers and subsets described above, which number correspond to subsets with 1 element? 2.22 What is the number of subsets of a set with n elements, containing a given element? 2.23 What is the number of integers with (a) at most n (decimal) digits; (b) exactly n digits? 2.24 How many bits (binary digits) does 2^100 have if written in base 2? 2.25 Find a formula for the number of digits of 2n.

2.4 Sequences

Motivated by the “encoding” of subsets as strings of 0’s and 1’s, we may want to determine the number of strings of length n composed of some other set of symbols, for example, a, b and c. The argument we gave for the case of 0’s and 1’s can be carried over to this case without any essential change. We can observe that for the first element of the string, we can choose any of a, b and c, that is, we have 3 choices. No matter what we choose, there are 3 choices for the second of the string, so the number of ways to choose the first two elements is 3^2 = 9. Going on in a similar manner, we get that the number of ways to choose the whole string is 3n. In fact, the number 3 has no special role here; the same argument proves the following theorem:

Theorem 2.2 The number of strings of length n composed of k given elements is kn.

The following problem leads to a generalization of this question. Suppose that a database has 4 fields: the first, containing an 8-character abbreviation of an employee’s name; the second, M or F for sex; the third, the birthday of the employee, in the format mm-dd-yy (disregarding the problem of not being able to distinguish employees born in 1880 from employees born in 1980); and the fourth, a jobcode which can be one of 13 possibilities. How many different records are possible? The number will certainly be large. We already know from theorem 2.2 that the first field may contain 26^8 > 200 , 000 , 000 , 000 names (most of these will be very difficult to pronounce, and are not likely to occur, but let’s count all of them as possibilities). The second field has 2 possible entries; the third, 36524 possible entries (the number of days in a century); the last, 13 possible entries. Now how do we determine the number of ways these can be combined? The argument we described above can be repeated, just “3 choices” has to be replaced, in order, by

“26^8 choices”, “2 choices”, “36524 choices” and “13 choices”. We get that the answer is 268 · 2 · 36524 · 13 = 198307192370919424. We can formulate the following generalization of theorem 2.

Theorem 2.3 Suppose that we want to form strings of length n so that we can use any of a given set of k 1 symbols as the first element of the string, any of a given set of k 2 symbols as the second element of the string, etc., any of a given set of kn symbols as the last element of the string. Then the total number of strings we can form is k 1 · k 2 ·... · kn.

As another special case, consider the problem: how many non-negative integers have exactly n digits (in decimal)? It is clear that the first digit can be any of 9 numbers (1, 2 ,... , 9), while the second, third, etc. digits can be any of the 10 digits. Thus we get a special case of the previous question with k 1 = 9 and k 2 = k 3 =... = kn = 10. Thus the answer is 9 · 10 n−^1. (cf. with exercise 2.3).

2.26 Draw a tree illustrating the way we counted the number of strings of length 2 formed from the characters a, b and c, and explain how it gives the answer. Do the same for the more general problem when n = 3, k 1 = 2, k 2 = 3, k 3 = 2. 2.27 In a sport shop, there are T-shirts of 5 different colors, shorts of 4 different colors, and socks of 3 different colors. How many different uniforms can you compose from these items? 2.28 On a ticket for a succer sweepstake, you have to guess 1, 2, or X for each of 13 games. How many different ways can you fill out the ticket? 2.29 We roll a dice twice; how many different outcomes can we have (a 1 followed by a 4 is different from a 4 followed by a 1)? 2.30 We have 20 different presents that we want to distribute to 12 children. It is not required that every child gets something; it could even happen that we give all the presents to the same child. In how many ways can we distribute the presents? 2.31 We have 20 kinds of presents; this time, we have a large supply from each. We want to give presents to 12 children. Again, it is not required that every child gets something; but no child can get two copies of the same present. In how many ways can we give presents?

2.5 Permutations

During the party, we have already encountered the problem: how many ways can we seat n people on n chairs (well, we have encountered it for n = 6 and n = 7, but the question is natural enough for any n). If we imagine that the seats are numbered, then a finding a seating for these people is the same as assigning them to the numbers 1, 2 ,... , n (or 0 , 1 ,... , n − 1 if we want to please the logicians). Yet another way of saying this is to order the people in a single line, or write down an (ordered) list of their names. If we have an ordered list of n objects, and we rearrange them so that they are in another order, this is called permuting them, and the new order is also called a permutation of the objects. We also call the rearrangement that does not change anything, a permutation (somewhat in the spirit of calling the empty set a set).

2.32 n boys and n girls go out to dance. In how many ways can they all dance simultaneously? (We assume that only couples of different sex dance with each other.) 2.33 (a) Draw a tree for Alice’s solution of enumerating the number of ways 6 people can play chess, and explain Alice’s argument using the tree. (b) Solve the problem for 8 people. Can you give a general formula for 2n people?

It is nice to know such a formula for the number of permutations, but often we just want to have a rough idea about how large it is. We might want to know, how many digits does 100! have? Or: which is larger, n! or 2n? In other words, does a set with n elements have more permutations or more subsets? Let us experiment a little. For small values of n, subsets are winning: 2^1 = 2 > 1! = 1, 22 = 4 > 2! = 2, 2^3 = 8 > 3! = 6. But then the picture changes: 24 = 16 < 4! = 24, 35 = 32 < 5! = 120. It is easy to see that as n increases, n! grows much faster than 2n: if we go from n to n + 1, then 2n^ grows by a factor of 2, while n! grows by a factor of n + 1. This shows that 100! > 2100 ; we already know that 2^100 has 31 digits, and hence it follows that 100! has at least 31 digits. What upper bound can we give on n!? It is trivial that n! < nn, since n! is the product of n factors, each of which is at most n. (Since most of them are smaller than n, the product is in fact much smaller.) In particular, for n = 100, we get that 100! < 100100 = 10^200 , so 100! has at most 200 digits. In general we know that, for n ≥ 4,

2 n^ < n! < nn.

These bounds are rather weak; for n = 10, the lower bound is 2^10 = 1024 while the upper bound is 10^10 (i.e., ten billion). We could also notice that n − 9 factors in n! are greater than, or equal to 10, and hence n! ≥ 10 n−^9. This is a much better bound for large n, but it is still far from the truth. For n = 100, we get that 100! ≥ 1091 , so it has at least 91 digits. There is a formula that gives a very good approximation of n!. We state it without proof, since the proof (although not terribly difficult) needs calculus.

Theorem 2.5 [Stirling’s Formula]

n! ∼

( (^) n e

)n √ 2 πn.

Here π = 3. 14... is the area of the circle with unit radius, e = 2. 718... is the basis of the natural logarithm, and ∼ means approximate equality in the precise sense that on the one hand n! ( (^) n e

)n √ 2 πn

→ 1 (n → ∞).

Both these funny irrational numbers e and π occur in the same formula!

So how many digits does 100! have? We know by Stirling’s Formula that

100! ≈ (100/e)^100 ·

200 π.

The number of digits of this number is its logarithm, in base 10, rounded up. Thus we get

lg(100!) ≈ 100 lg(100/e) + 1 + lg

2 π = 157. 969...

So the number of digits in 100! is about 158 (actually, this is the right value).

2.34 (a) Which is larger, n or n(n − 1)/2? (b) Which is larger, n^2 or 2n? 2.35 (a) Prove that 2n^ > n^3 if n is large enough. (b) Use (a) to prove that 2n/n^2 becomes arbitrarily large if n is large enough.