136 views

Uploaded by black2lamin

save

- wolstenholme
- MTAP Reviewer Grade 3
- jhtp4_02
- Primes and Divisors 2
- Java Operator Precedence
- Abstract
- Rules of Inference
- Haoudout1-4
- Grade 8 Skill Sheets
- A Note on the Smarandache Near-To-Primorial Function
- SurveyofGreen-TaoTheorem
- Goldbach's Strong Conjecture
- Infix2Postfix
- Stellarium User Guide 0.18.2 1
- course syllabus
- Number Systems
- Readme
- 6th grade math practice 2
- Understanding Core Programming part2
- EMMANUEL HIGH SCHOOL MATH.docx
- Diophantine Equations
- user-manual.pdf
- XTM 5 Series HardwareGuide
- Remainder theorem.docx
- French 2013
- Prelim2015 Sol
- c Questions
- The Natural Numbers
- maths 0580 2014
- ch03
- Discrete Mathematics 2005
- Discrete Mathematics 2005
- 14102008 Jitmm a15 Ramasoota Tuberculosis
- Full Example
- Multi Algoerithm Kruppa-slides
- What is the Difference Between L1 Cache and L2 Cache

You are on page 1of 104

David A. SANTOS dsantos@ccp.edu

M M ath D at em N D isc he m atic N otes D isc rete at r ic s N otes D iscr ete s N ot es D iscr ete Ma N otes D iscr ete Ma the N otes D iscr ete Ma the mat ot isc et M th ma ics es D em ti a r e D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs N isc et M th c re e M ath em atic s N ote te a s o s M ath ema tics No tes M ath ema tics No tes M ath ema tics No tes D M ath ema tics No tes D iscr M ath ema tics No tes D iscr ete isc et at em tic N te e he s D m atic s N otes D isc rete at r ic s N otes D iscr ete s N ot es D iscr ete Ma N otes D iscr ete Ma the N otes D iscr ete Ma the mat ot es D iscr ete Ma them mat ics i D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs N isc et t e Mat hem ati cs N ot re te Ma he a cs o es M th ma tics No tes M ath ema tics No tes M ath ema tics No tes D M ath ema tics No tes D iscr M ath ema tics No tes D iscr ete i et at em tic N te e he s D sc m atic s N otes D isc rete at r ic s N otes D iscr ete Ma s N ot es D iscr ete Ma the N otes D iscr ete Ma the mat ot es D iscr ete Ma them mat ics i D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs N isc et M th c re e M ath em atic s N ote te a s o s M ath ema tics No tes M ath ema tics No tes M ath ema tics No tes D M ath ema tics No tes D iscr M ath ema tics No tes D iscr ete isc et at em tic N te e he s D m atic s N otes D isc rete at r ic s N otes D iscr ete s N ot es D iscr ete Ma N otes D iscr ete Ma the N otes D iscr ete Ma the mat ot m ic isc et M th es D em ati s a r e D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs N isc et t e Mat hem ati cs N ot re te Ma he a cs o es M th ma tics No tes M ath ema tics No tes M ath ema tics No tes D M ath ema tics No tes D iscr M ath ema tics No tes D iscr ete i et at em tic N te e he s D sc m atic s N otes D isc rete at r ic s N otes D iscr ete s N ot es D iscr ete Ma N otes D iscr ete Ma the N otes D iscr ete Ma the mat ot es D iscr ete Ma them mat ics i D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs N isc et M th cs re e M ath em atic N ote te a s o s M ath ema tics No tes M ath ema tics No tes M ath ema tics No tes D M ath ema tics No tes D iscr M ath ema tics No tes D iscr ete i et at em tic N te e he s D sc m atic s N otes D isc rete at r ic s N otes D iscr ete Ma s N ot es D iscr ete Ma the N otes D iscr ete Ma the mat ot isc et M th ma ics es D em ti a r e D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs D iscr ete Ma them ati cs N isc et M th c re e M ath em atic s N ote te a s o s M ath ema tics No tes M ath ema tics No tes M ath ema tics No tes D M ath ema tics No tes D iscr M ath ema tics No tes D iscr ete em ti isc et at c N tes D e he m atic s N otes D isc rete at r ic s N otes D iscr ete s N ot es D iscr ete Ma N otes D iscr ete Ma the N otes D iscr ete Ma the mat ot es D iscr ete Ma them mat ics i D iscr ete Ma them ati cs D iscr ete Ma them ati cs isc et M th c re e M ath em atic s te a s M ath ema tics No at em tic N te he s m atic s N otes at ic s N otes s N ot ot es Dis es D cr D iscr ete isc et re e te

ii

Contents

Preface GNU Free Documentation License 1. APPLICABILITY AND DEFINITIONS . . . . . . 2. VERBATIM COPYING . . . . . . . . . . . . . . . 3. COPYING IN QUANTITY . . . . . . . . . . . . . 4. MODIFICATIONS . . . . . . . . . . . . . . . . . . 5. COMBINING DOCUMENTS . . . . . . . . . . . . 6. COLLECTIONS OF DOCUMENTS . . . . . . . . 7. AGGREGATION WITH INDEPENDENT WORKS 8. TRANSLATION . . . . . . . . . . . . . . . . . . . 9. TERMINATION . . . . . . . . . . . . . . . . . . . 10. FUTURE REVISIONS OF THIS LICENSE . . . . 1 Pseudocode 1.1 Operators . . . . . . . . . . 1.2 Algorithms . . . . . . . . . 1.3 Arrays . . . . . . . . . . . . 1.4 If-then-else Statements 1.5 The for loop . . . . . . . . 1.6 The while loop . . . . . . Homework . . . . . . . . . . . . . Answers . . . . . . . . . . . . . . iii v v v v v vi vi vi vi vi vi 1 1 2 3 4 5 8 10 11 14 14 15 17 19 20 22 26 26 29 31 33 34 36 36 4 Relations and Functions 4.1 Partitions and Equivalence Relations . . . . . . . . . 4.2 Functions . . . . . . . . . . . . . . . . . . . . . . . 5 Number Theory 5.1 Division Algorithm . . . . 5.2 Greatest Common Divisor 5.3 Non-decimal Scales . . . . 5.4 Congruences . . . . . . . 5.5 Divisibility Criteria . . . . Homework . . . . . . . . . . . . Answers . . . . . . . . . . . . . 38 38 40 44 44 46 48 49 51 53 54 57 57 59 60 62 64 66 67 72 73 78 78 82 85 86 87 88 89 89 92 93 93 95 97 97

. . . . . . . . . .

. . . . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

6 Enumeration 6.1 The Multiplication and Sum Rules . . . . 6.2 Combinatorial Methods . . . . . . . . . . 6.2.1 Permutations without Repetitions 6.2.2 Permutations with Repetitions . . 6.2.3 Combinations without Repetitions 6.2.4 Combinations with Repetitions . . 6.3 Inclusion-Exclusion . . . . . . . . . . . . Homework . . . . . . . . . . . . . . . . . . . . Answers . . . . . . . . . . . . . . . . . . . . . 7 Sums and Recursions 7.1 Famous Sums . . . . . . . 7.2 First Order Recursions . . 7.3 Second Order Recursions . 7.4 Applications of Recursions Homework . . . . . . . . . . . . Answers . . . . . . . . . . . . . 8 Graph Theory 8.1 Simple Graphs . . 8.2 Graphic Sequences 8.3 Connectivity . . . 8.4 Traversability . . . 8.5 Planarity . . . . . . Homework . . . . . . . . Answers . . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

2 Proof Methods 2.1 Proofs: Direct Proofs . . . . . . 2.2 Proofs: Mathematical Induction 2.3 Proofs: Reductio ad Absurdum . 2.4 Proofs: Pigeonhole Principle . . Homework . . . . . . . . . . . . . . . Answers . . . . . . . . . . . . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

3 Logic, Sets, and Boolean Algebra 3.1 Logic . . . . . . . . . . . . . . . . . . . 3.2 Sets . . . . . . . . . . . . . . . . . . . . 3.3 Boolean Algebras and Boolean Operations 3.4 Sum of Products and Products of Sums . . 3.5 Logic Puzzles . . . . . . . . . . . . . . . Homework . . . . . . . . . . . . . . . . . . . . Answers . . . . . . . . . . . . . . . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

Preface

These notes started in the Spring of 2004, but contain material that I have used in previous years. I would appreciate any comments, suggestions, corrections, etc., which can be addressed at the email below. David A. Santos dsantos@ccp.edu

Things to do: • Weave functions into counting, a la twelfold way. . . `

iii

Permission is granted to copy. A copy of the license is included in the section entitled “GNU Free Documentation License”. distribute and/or modify this document under the terms of the GNU Free Documentation License. no Front-Cover Texts.2 or any later version published by the Free Software Foundation. Version 1. with no Invariant Sections. .iv Copyright c 2007 David Anthony SANTOS. and no Back-Cover Texts.

This License is a kind of “copyleft”. with or without modifying it. and standard-conforming simple HTML. because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. you may accept compensation in exchange for copies. Any member of the public is a licensee.GNU Free Documentation License Version 1. but not required. A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. Texinfo input format. that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. textbook. can be treated as verbatim copying in other respects. VERBATIM COPYING You may copy and distribute the Document in any medium. The “Cover Texts” are certain short passages of text that are listed. modify or distribute the work in a way requiring permission under copyright law. provided that you release the Modiﬁed Version under precisely this License. and that you add no other conditions whatsoever to those of this License. These Warranty Disclaimers are considered to be included by reference in this License. clearly and legibly. and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. regardless of subject matter or whether it is published as a printed book. such as “Acknowledgements”. 3.2001. with the Modiﬁed Version ﬁlling the role of the Document. 1.2002 Free Software Foundation. as Front-Cover Texts or Back-Cover Texts. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. all these Cover Texts: Front-Cover Texts on the front cover. You may add other material on the covers in addition. Examples of suitable formats for Transparent copies include plain ASCII without markup. and the Document’s license notice requires Cover Texts. Both covers must also clearly and legibly identify you as the publisher of these copies. and continue the rest onto adjacent pages. If you use the latter option. that you contact the authors of the Document well before redistributing any large number of copies. 4. (Here XYZ stands for a speciﬁc section name mentioned below. unlimited in duration.2. represented in a format whose speciﬁcation is available to the general public. to give them a chance to provide you with an updated version of the Document. Inc. “Endorsements”. If a section does not ﬁt the above deﬁnition of Secondary then it is not allowed to be designated as Invariant. philosophical. The “Document”. For works in formats which do not have any title page as such. has been arranged to thwart or discourage subsequent modiﬁcation by readers is not Transparent. for a printed book. or with modiﬁcations and/or translated into another language. and the license notice saying this License applies to the Document are reproduced in all copies. either copied verbatim. LaTeX input format. SGML or XML for which the DTD and/or processing tools are not generally available. thus licensing distribution and modiﬁcation of the Modiﬁed Version to whoever possesses a copy of it. legibly. Examples of transparent image formats include PNG. or of legal. or other functional and useful document “free” in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it. either commercially or noncommercially. to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. commercial. if the Document is in part a textbook of mathematics. (Thus. as long as they preserve the title of the Document and satisfy these conditions. SGML or XML using a publicly available DTD. and the machine-generated HTML. you must take reasonably prudent steps. PostScript or PDF produced by some word processors for output purposes only. A copy that is not “Transparent” is called “Opaque”. in any medium. refers to any such manual or work. It is requested. preceding the beginning of the body of the text. “Title Page” means the text near the most prominent appearance of the work’s title. An image format is not Transparent if used for any substantial amount of text. free of added material. ethical or political position regarding them. If the Document does not identify any Invariant Sections then there are none. The front cover must present the full title with all words of the title equally prominent and visible. you should put the ﬁrst ones listed (as many as ﬁt reasonably) on the actual cover. However. and Back-Cover Texts on the back cover. which means that derivative works of the document must themselves be free in the same sense. If you publish or distribute Opaque copies of the Document numbering more than 100. the material this License requires to appear in the title page. in the notice that says that the Document is released under this License. you must do these things in the Modiﬁed Version: v . a Secondary Section may not explain any mathematics.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this deﬁnition. the copyright notices. If the required texts for either cover are too voluminous to ﬁt legibly. or “History”. to use that work under the conditions stated herein. in the notice that says that the Document is released under this License. as being those of Invariant Sections. You accept the license if you copy. this License preserves for the author and publisher a way to get credit for their work. and you may publicly display copies. We recommend this License principally for works whose purpose is instruction or reference. it can be used for any textual work. under the same conditions stated above. you must either include a machine-readable Transparent copy along with each Opaque copy. PostScript or PDF designed for human modiﬁcation. It complements the GNU General Public License. Copying with changes limited to the covers. MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document. The “Invariant Sections” are certain Secondary Sections whose titles are designated. below. either commercially or noncommercially. Fifth Floor. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors. or absence of markup. You may also lend copies. A Front-Cover Text may be at most 5 words. while not being considered responsible for modiﬁcations made by others. COPYING IN QUANTITY If you publish printed copies (or copies in media that commonly have printed covers) of the Document.) The relationship could be a matter of historical connection with the subject or with related matters. and a Back-Cover Text may be at most 25 words. and is addressed as “you”. A “Modiﬁed Version” of the Document means any work containing the Document or a portion of it. numbering more than 100. that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work. which is a copyleft license designed for free software. A copy made in an otherwise Transparent ﬁle format whose markup. Boston. “Dedications”. We have designed this License in order to use it for manuals for free software. But this License is not limited to software manuals. XCF and JPG. provided that this License. Secondarily. If you distribute a large enough number of copies you must also follow the conditions in section 3. plus such following pages as are needed to hold. when you begin distribution of Opaque copies in quantity. 51 Franklin St. A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. The Document may contain zero Invariant Sections. Such a notice grants a world-wide. but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License. royalty-free license. November 2002 Copyright c 2000. the title page itself. but changing it is not allowed. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. The “Title Page” means. 2. or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document. A “Transparent” copy of the Document means a machine-readable copy. you must enclose the copies in covers that carry. Preamble The purpose of this License is to make a manual. MODIFICATIONS You may copy and distribute a Modiﬁed Version of the Document under the conditions of sections 2 and 3 above. In addition.

then add an item describing the Modiﬁed Version as stated in the previous sentence. in the form shown in the Addendum below. Section numbers or the equivalent are not considered part of the section titles. or else a unique number. or if the original publisher of the version it refers to gives permission. under the terms deﬁned in section 4 above for modiﬁed versions. modify. Preserve the network location. sublicense. In the combination. provided it contains nothing but endorsements of your Modiﬁed Version by various parties–for example. year. 5. in or on a volume of a storage or distribution medium. J. Preserve any Warranty Disclaimers. from you under this License will not have their licenses terminated so long as such parties remain in full compliance. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modiﬁed Version. If there is no section Entitled “History” in the Document. then if the Document is less than one half of the entire aggregate. be listed in the History section of the Document). Preserve the Title of the section. C. Such a section may not be included in the Modiﬁed Version. as authors. “Dedications”. statements of peer review or that the text has been approved by an organization as the authoritative deﬁnition of a standard.gnu. You may use the same title as a previous version if the original publisher of that version gives permission. 7. See http://www. or rights. If the Cover Text requirement of section 3 is applicable to these copies of the Document. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer. provided that you also include the original English version of this License and the original versions of those notices and disclaimers. is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. . You may omit a network location for a work that was published at least four years before the Document itself. K. If the Modiﬁed Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document. and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. Replacing Invariant Sections with translations requires special permission from their copyright holders. 10. provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. The combined work need only contain one copy of this License. this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. in parentheses. one or more persons or entities responsible for authorship of the modiﬁcations in the Modiﬁed Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. and publisher of the Modiﬁed Version as given on the Title Page.org/copyleft/. authors. O. Use in the Title Page (and on the covers. unmodiﬁed. Add an appropriate copyright notice for your modiﬁcations adjacent to the other copyright notices. if any. Otherwise they must appear on printed covers that bracket the whole aggregate. and replace the individual copies of this License in the various documents with a single copy that is included in the collection. TERMINATION You may not copy. Do not retitle any existing section to be Entitled “Endorsements” or to conﬂict in title with any Invariant Section. given in the Document for public access to a Transparent copy of the Document. Preserve all the copyright notices of the Document. and that you preserve all their Warranty Disclaimers. and follow this License in all other respects regarding verbatim copying of that document. B. F. if it has fewer than ﬁve). FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new. or “History”. parties who have received copies. Preserve the section Entitled “History”. and a passage of up to 25 words as a Back-Cover Text. the name of the original author or publisher of that section if known. or the electronic equivalent of covers if the Document is in electronic form. modify. Preserve all the Invariant Sections of the Document. List on the Title Page. and will automatically terminate your rights under this License. forming one section Entitled “History”. provided you insert a copy of this License into the extracted document. If the Document speciﬁes that a particular numbered version of this License “or any later version” applies to it. if there were any. TRANSLATION Translation is considered a kind of modiﬁcation. If there are multiple Invariant Sections with the same name but different contents. 9. 8. to the end of the list of Cover Texts in the Modiﬁed Version. and from those of previous versions (which should. G. immediately after the copyright notices. L. unless they release you from this requirement. E. State on the Title page the name of the publisher of the Modiﬁed Version. D. make the title of each such section unique by adding at the end of it. If the Document does not specify a version number of this License. but may differ in detail to address new problems or concerns.vi A. as the publisher. If a section in the Document is Entitled “Acknowledgements”. Any other attempt to copy. Include an unaltered copy of this License. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. and multiple identical Invariant Sections may be replaced with a single copy. but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. Delete any section Entitled “Endorsements”. and list them all as Invariant Sections of your combined work in its license notice. previously added by you or by arrangement made by the same entity you are acting on behalf of. For any section Entitled “Acknowledgements” or “Dedications”. M. the original version will prevail. I. if any) a title distinct from that of the Document. revised versions of the GNU Free Documentation License from time to time. These may be placed in the “History” section. You may add a section Entitled “Endorsements”. N. You must delete all sections Entitled “Endorsements”. a license notice giving the public permission to use the Modiﬁed Version under the terms of this License. sublicense or distribute the Document is void. However. you may at your option designate some or all of these sections as invariant. or distribute the Document except as expressly provided for under this License. provided that you include in the combination all of the Invariant Sections of all of the original documents. and all the license notices in the Document. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License. so you may distribute translations of the Document under the terms of section 4. If the Document already includes a cover text for the same cover. create one stating the title. To do this. and likewise the network locations given in the Document for previous versions it was based on. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice. likewise combine any sections Entitled “Acknowledgements”. and any Warranty Disclaimers. the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate. you have the option of following the terms and conditions either of that speciﬁed version or of any later version that has been published (not as a draft) by the Free Software Foundation. Include. you may not add another. together with at least ﬁve of the principal authors of the Document (all of its principal authors. Such new versions will be similar in spirit to the present version. add their titles to the list of Invariant Sections in the Modiﬁed Version’s license notice. You may add a passage of up to ﬁve words as a Front-Cover Text. and distribute it individually under this License. the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title. COMBINING DOCUMENTS You may combine the Document with other documents released under this License. year. and any sections Entitled “Dedications”. on explicit permission from the previous publisher that added the old one. You may include a translation of this License. and publisher of the Document as given on its Title Page. Preserve its Title. When the Document is included in an aggregate. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works. unaltered in their text and in their titles. Each version of the License is given a distinguishing version number. but you may replace the old one. These titles must be distinct from any other section titles. H. you must combine any sections Entitled “History” in the various original documents. new authors. you may choose any version ever published (not as a draft) by the Free Software Foundation. and add to it an item stating at least the title. 6. You may extract a single document from such a collection.

1961 mod 37 = 0. and 1966 mod 37 = 5. Common arithmetical binary operators that we will use are + (plus) to indicate the sum of two numbers and − (minus) to indicate a difference of two numbers. 2 Deﬁnition (Unary Operators) A unary operator is an operator acting on a single operand. There is a further arithmetical binary operator that we will use. 2. 1. . 1 . 15 mod 38 = 15. Observe that this remainder is one of the b numbers 0. In the case when at least one of a or b is negative. b > 0. for example. a mod b is the integral non-negative remainder when a is divided by b.. b − 1. used to perform an action on some entities. 1. 5 Example We have 38 mod 15 = 8. we will leave a mod b undeﬁned. These entities are called the operands.Chapter 1 Pseudocode In this chapter we study pseudocode. We will also use ∗ (asterisk) to denote multiplication and / (slash) to denote division. Common arithmetical unary operators are + (plus) which indicates a positive number. and − (minus) which indicates a negative number. 3 Deﬁnition (Binary Operators) A binary operator is an operator acting on two operands. which will allow us to mimic computer language in writing algorithms. or string of characters..1 Operators 1 Deﬁnition (Operator) An operator is a character.. 4 Deﬁnition (mod Operator) The operator mod is deﬁned as follows: for a ≥ 0.

7 Example 15 − 3 ∗ 4 = 3 but (15 − 3) ∗ 4 = 48. Left-associative operators are executed from left to right and right-associative operators are executed from right to left. we will use the word return to indicate this output. b. 10 Example (Area of a Trapezoid) Write an algorithm that gives the area of a trapezoid whose height is h and bases are a and b. Recall from algebra that multiplication and division have the same precedence. Solution: One possible solution is Algorithm 1.2 Chapter 1 6 Deﬁnition (Precedence of Operators) The priority or precedence of an operator is the order by which it is applied to its operands.2 Algorithms In pseudocode parlance an algorithm is a set of instructions that accomplishes a task in a ﬁnite amount of time. we deﬁne the associativity to be the order which determines which of the operators will be executed ﬁrst. 1. Parentheses ( ) are usually used to coerce precedence among operators. If the algorithm produces a single output that we might need afterwards.1: A REAT RAPEZOID(a. When two or more operators of the same precedence are in an expression. and their precedence is higher than addition and subtraction. The arithmetical binary operators are all left associative whilst the arithmetical unary operators are all right associative. 9 Example 12 mod 5 + 3 ∗ 3 = 11 but 12 mod (5 + 3) ∗ 3 = 12 mod 8 ∗ 3 = 4 ∗ 3 = 12. The mod operator has the same precedence as multiplication and addition. 8 Example 12 ∗ (5 mod 3) = 24 but (12 ∗ 5) mod 3 = 0. h) return (h ∗ a+b ) 2 .2.

b. and c.2: A REAOF T RIANGLE(a. 11 Example (Heron’s Formula) Write an algorithm that will give the area of a triangle with sides a. Solution: A possible solution is Algorithm 1.25 ∗ We have used Heron’s formula Area = where s= is the semi-perimeter of the triangle.2. . 12 Deﬁnition The symbol ← is read “gets” and it is used to denote assignments of value. b. c) return (.

a+b+c 2 2 . (a + b + c) ∗ (b + c − a) ∗ (c + a − b) ∗ (a + b − c)) s(s − a)(s − b)(s − c) = 1 4 (a + b + c)(b + c − a)(c + a − b)(a + b − c).

. y) t←x y←t If we approached the problem in the following manner Algorithm 1.4: S WAP W RONG (x.3: S WAP(x.2. the contents of x becomes that of y and viceversa.Arrays 3 13 Example (Swapping variables) Write an algorithm that will interchange the values of two variables x and y. comment: y now receives the original value of x. y) x←5 y←6 x←y y←x comment: First store x in temporary place comment: x has a new value.2. that is. Solution: We introduce a temporary variable t in order to store the contents of x in y without erasing the contents of y: Algorithm 1.

the contents of x becomes that of y and viceversa. we do not obtain a swap.5: S WAP 2(x. 14 Example (Swapping variables 2) Write an algorithm that will interchange the values of two variables x and y. x←y comment: x = 6 now. . without introducing a third variable..e. i. y) x ← x+y x ← x−y y ← x−y comment: x = a + b and y = b. Solution: The idea is to use sums and differences to store the variables. that is. comment: y = a and x = a + b − a = b. 6. Algorithm 1.2. comment: y = a + b − b = a and x = a + b. comment: y takes the current value of x. Assume that initially x = a and y = b.

. X[n − 1]) and all the n coordinates X[k] belong to the same set. . Thus if X is 1-dimensional array of length n then X = (X[0]. . We will follow the C-C++-Java convention of indexing the arrays from 0. X[1]. We will always declare the length of the array at the beginning of a code fragment by means of a comment.3 Arrays 15 Deﬁnition An array is an aggregate of homogeneous types. Thus if Y is a 2-dimensional array with 2 rows and 3 columns then å è Y= Y [0][0] Y [0][1] Y [0][2] . The length of the array is the number of entries it has. A 2-dimensional array is akin to a mathematical matrix.. 1. A 1-dimensional array is akin to a mathematical vector. Y [1][0] Y [1][1] Y [1][2] 3 .

. statementA − I statementB − 1 . then .2: M AX(x. else statementB − J and evaluates as follows. . . Solution: Here is a possible approach. Algorithm 1.4.4 Chapter 1 1.4 If-then-else Statements 16 Deﬁnition The If-then-else control statement has the following syntax: if expression statementA − 1 . If expression is true then all statementA ’s are executed. Otherwise all statementB’s are executed. 17 Example (Maximum of 2 Numbers) Write an algorithm that will determine the maximum of two numbers. y) if x ≥ y then return (x) else return (y) .

Solution: Here is a possible approach using the preceding function.3: M AX 3(x. y)) else return (z) . y) ≥ z then return (M AX(x. Algorithm 1. y. z) if M AX(x.4. 18 Example (Maximum of 3 Numbers) Write an algorithm that will determine the maximum of three numbers.

) then . You are not allowed to use any boolean operators like and.) else output (Goodbye. 19 Example (Compound Test) Write an algorithm that prints “Hello” if one enters a number between 4 and 6 (inclusive) and “Goodbye” otherwise.) else output (Goodbye. Algorithm 1. etc.4: H ELLO G OOD B YE(x) if x >= 4 if x <= 6 then output (Hello.4. Solution: Here is a possible answer. or.

4 .

5 The for loop 20 Deﬁnition The for loop has either of the following syntaxes:1 for indexvariable ← lowervalue to uppervalue do statements or for indexvariable ← uppervalue downto lowervalue do statements Here lower value and upper value must be non-negative integers with uppervalue ≥ lowervalue. Solution: Here is a possible answer.5. 21 Example (Factorial Integers) Recall that for a non-negative integer n the quantity n! (read “n factorial”) is deﬁned as follows. . 0! = 1 and if n > 0 then n! is the product of all the integers from 1 to n inclusive: n! = 1 · 2 · · ·n. Algorithm 1. Write an algorithm that given an arbitrary non-negative integer n outputs n!.3: FACTORIAL(n) comment: Must input an integer n ≥ 0. For example 5! = 1 · 2 · 3 · 4 · 5 = 120.The for loop 5 1.

.5. f ←1 if n = 0 then return ( f ) for i ← 1 to n else do f ← f ∗ i return ( f ) 22 Example (Positive Integral Powers 1) Write an algorithm that will compute xn . Thus a possible answer would be Algorithm 1. n) power ← 1 for i ← 1 to n do power ← x ∗ power return (power) In example 34 we shall examine a different approach. Without introducing another array. Solution: We can approach this problem as we did the factorial function in example 21. .4: P OWER 1(x. X[n − 1]) is given. put its entries in . 23 Example (Reversing an Array) An array (X[0]. . where x is a given real number and n is a given positive integer.

5 . reverse order. and Java is slightly different and makes the for loop much more powerful than the one we are presenting here. C++. 1 The syntax in C. X[1] ↔ X[n − 2]. Solution: Observe that we exchange X[0] ↔ X[n − 1].

5: R EVERSE A RRAY (n. for i ← 0 to (n − 2)/2 do Swap(X[i]. say the one of example 13. which happens if and only if 2i ≤ n − 2. which happens if and only if i ≤ (n − 2)/2 .6 and in general Chapter 1 This holds as long as i < n − i − 1.Thus a possible answer is Algorithm 1. X) comment: X is an array of length n. We now use a swapping algorithm. X[n − i − 1]) .5. that is 2i < n − 1.

Since 5 = 7. the programme prints 5. Since 3 = 7. 25 Example What will the following algorithm print? Algorithm 1. i = 5. ) prints whatever is enclosed in the parentheses. . Since 7 = 7. The programme ends up printing 3456.5. i = 7. We will use it here and will abandon it once we study the while loop. Many a programmer considers using the break command an ugly practice. in sequence. i = 4. The command output(. the programme prints 4. i = 6. the programme prints 3. the programme prints 6. the programme halts and nothing else is printed. X[i] ↔ X[n − i − 1]. Since 6 = 7.6: P RINTING (·) for i ← 3 to 11 if i = 7 then break do else output (i) Solution: We have. 24 Deﬁnition The command break stops the present control statement and jumps to the next control statement. i = 3. Since 4 = 7. . .

max ← X[0] for i ← 1 to n − 1 if X[i] > max do then max = X[i] return (max) 6 .5. Solution: We declare the ﬁrst value of the array (the 0-th entry) to be the maximum (a sentinel value). Algorithm 1. that entry is declared the maximum. If an entry is found to be larger than it. 26 Example (Maximum of n Numbers) Write an algorithm that determines the maximum element of a 1-dimensional array of n elements. Then we successively compare it to other n − 1 entries. X) comment: X is an array of length n.7: M AX E NTRYINA RRAY (n.

.

n = 2.5. Thus n must have a prime factor ≤ n. Observe that √ 103 = 10. If one of these primes divides 103 then 103 is not a prime.) √ comment: If n ≥ 4. which is a contradiction. u 28 Example To determine whether 103 is prime we proceed as follows.3 We now divide 103 by every prime ≤ 10. 30 Example (Eratosthenes’ Primality Testing) Given a positive integer n write an algorithm to determine whether it is prime. The not unary operator changes the status of a boolean variable from true to false and viceversa. Solution: Here is a possible approach. Algorithm 1.2 To determine whether an integer is prime we rely on the following result. Proof: If n is prime there is nothing to prove. Then n can be written as √ the √ √ product n = ab with 1 < a ≤ b.) ﬂag ← true √ for i ← 2 to n if n mod i = 0 ﬂag ← false do else then break if ﬂag = true then output (n is prime.) else output (Not prime. Assume then than n is composite. n smallest factor is i. If √ every prime factor of n were > n then we would have both a > n and b > n √ √ then we would have n = ab > n n = n. then n ≥ 2.) . Its smallest factor is 2. whence 103 is prime since none of these remainders is 0.) if n = 3 then output (n is prime. 29 Deﬁnition (Boolean Variable) A boolean variable is a variable that only accepts one of two possible values: true or false.8: I S P RIME 1(n) comment: n is a positive integer. 103 mod 3 = 1. n = 3 are necessary because in our version of the for loop we need the lower index to be at most the upper index.) if n = 2 then output (n is prime.The for loop 7 Recall that a positive integer p > 1 is a prime if its only positive factors of p are either 1 or p. Either n is prime or n has a prime factor ≤ √ n. 103 is a prime. 27 Theorem Let n > 1 be a positive integer. Otherwise. 103 mod 7 = 5. if n = 1 then output (n is a unit. if n > 3 if n mod 2 = 0 then output (n is even. A quick division ﬁnds 103 mod 2 = 1. The special cases n = 1. An integer greater than 1 which is not prime is said to be composite. 103 mod 5 = 3.

x denotes the ﬂoor of x. that is. then 2 Thus 3 Here 1 is neither prime nor composite. 7 . the integer just to the left of x if x is not an integer and x otherwise.

Person number 4 enters and changes the status (from open to closed and viceversa) of all doors whose numbers are multiples of 4. We will see in example 35 how to avoid it.4 Algorithm 1. otherwise he opens it. Person number 1 enters and closes all the doors. Person number 2 enters and opens all the doors whose numbers are multiples of 2. Person number 3 enters and if a door whose number is a multiple of 3 is open then he closes it.9: L OCKER ROOM P ROBLEM (n. as it uses the break statement. for i ← 1 to n do Locker[i] ← false comment: From open to closed and vice-versa in the second loop . for j ← 2 to n for k ← j to n do do if k mod j = 0 then Locker[k] = not Locker[k] for l ← 1 to n if Locker[l] = false do then output (Locker l is closed. We use an array Locker of size n + 1 to denote the lockers (we will ignore Locker[0]).) . this algorithm is unsatisfactory. Solution: Here is one possible approach. 31 Example (The Locker-room Problem) A locker room contains n lockers. The value true will denote an open locker and the value false will denote a closed locker. Write an algorithm to determine which lockers are closed.5. Initially all doors are open. numbered 1 through n. Locker) comment: Locker is an array of size n + 1. and so forth till person number n enters and changes the status of door number n.8 Chapter 1 From a stylistic point of view. comment: Closing all lockers in the ﬁrst for loop.

33 Example (Different Elements in an Array) An array X satisﬁes X[0] ≤ X[1] ≤ · · · ≤ X[n − 1]. i←0 different ← 1 while i = n − 1 i ← i+1 do if x[i] = x[i − 1] then different ← different + 1 return (different) will later see that those locker doors whose numbers are squares are the ones which are closed. 1. .2: D IFFERENT(n. Algorithm 1.6.6 The while loop 32 Deﬁnition The while loop has syntax: while test do body of loop The commands in the body of the loop will be executed as long as test evaluates to true. Write an algorithm that ﬁnds the number of entries which are different. X) comment: X is an array of length n. Solution: Here is one possible approach.

4 We 8 .

From the point of view of computing time. n) power ← 1 c←x k←n while k = 0 if k mod 2 = 0 k ← k/2 then c ← c∗c do else return (power) k ← k−1 power ← power ∗ c . Basically it consists of writing n in binary. A more efﬁcient approach is the following. where a is a given real number and n is a given positive integer. that solution is unsatisfactory. Solution: We have already examined this problem in example 22. For example. if n = 11 we compute x → x2 → x4 → x8 . which could tax the computer memory if n is very large.The while loop 9 34 Example (Positive Integral Powers 2) Write an algorithm that will compute an .6. and we stop when 2k ≤ n < 2k+1 . as it would incur into n multiplications.3: P OWER 2(x. k Algorithm 1. We now write 11 = 8 + 2 + 1 and so x11 = x8 x2 x. We successively square x getting a sequence x → x2 → x4 → x8 → · · · → x2 .

35 Example Here is the I S P RIME 1 programme from example 30 with while loops replacing the for loops. If n > 3. For instance. as it is not necessary to divide it by even integers. we do not need to use the break command if we incorporate the conditions for breaking in the test of the loop. it is more efﬁcient than it. Also. the code for i ← k to n do something is equivalent to i←k while i <= n i ← i+1 do something But more can be achieved from the while loop. The while loop can be used to replace the for loop. then n is divided successively by odd integers. and in fact. we could jump t steps at a time by declaring i ← i + t. 9 . For. instead of jumping the index one-step-at-a-time.

if n = 1 then output (n is a unit.) if n > 3 if n mod 2 = 0 then output (n is even.) ﬂag ← true i←1 √ while i <= n and ﬂag = true i ← i+2 then do if n mod i = 0 else then ﬂag ← false if ﬂag = true then output (n is prime. Its smallest factor is 2.6: I S P RIME 2(n) comment: n is a positive integer. n smallest factor is i.) if n = 2 then output (n is prime.) .10 Algorithm 1.) if n = 3 then output (n is prime.6.) else output (Not prime.

7: M YSTERY(n) x←0 i←1 while n > 1 if n ∗ i > 4 then x ← x + 2n do else x ← x + n n ← n−2 i ← i+1 return (x) .6. Algorithm 1. Chapter 1 Homework 36 Problem What will the following algorithm return for n = 5? You must trace the algorithm carefully. outlining all your steps.

8: M YSTERY(n) x←0 while n > 0 for i ← 1 to n for j ¨ i to n ← do do x ← i j + x n ← n−1 return (x) do . 37 Problem What will the following algorithm return for n = 3? Algorithm 1.6.

10 .

fn+1 = fn + fn−1 . Without using another array reorder the array in the form X[m] → X[m + 1] → . For example. n = 1. 9. i = 1. 10.9: R EVERSE(n) comment: n is a positive integer. Write an algorithm that ﬁnds the n-th Fibonacci number. n ≥ 1. For instance. Hence x = 16 is returned. without taking the order of the summands into account. f1 = 1. → X[m − 1]. Write an algorithm to generate all the partitions of a given integer n. of length 5. n ∗ i > 4 and thus x = 10. Since n ∗ i > 4. 2 + 2. . one mod operation. 3 + 1. < X[m − 1] < X[m] < . . 9. . 10. 9. 5/3 = 1. the output should be 674321. the partitions of 4 are (in “alphabetic order” and with the summands written in decreasing order) 1 + 1 + 1 + 1. For example 5/2 = 2. Now n = 3. . Finally. → X[m + n − 1] → X[0] → X[1] → . f2 = 1. 38 Here is a possible approach.6. 7. . 9. Use only one while loop. and we go a second turn around the loop. 40 Problem The Fibonacci Sequence is deﬁned recursively as follows: f0 = 0. 8. do x ← x ∗ 10 + n mod 10 comment: We now truncate a digit of the input. 8. i = 2. 43 Problem A partition of the strictly positive integer n is the number of writing n as the sum of strictly positive summands. . Answers 36 In the ﬁrst turn around the loop. i = 3. . 1. in the sequence 7. 4. 39 Problem Given is an array of length m + n.Answers 11 38 Problem Assume that the division operator / acts as follows on the integers: if the division is not even. which is sorted in increasing order: X[0] < X[1] < . 2. one multiplication by 10 and one division by 10. Algorithm 1. Assuming this write an algorithm that reverses the digits of a given integer. 9. For example. 41 Problem Write an algorithm which reads a sequence of real numbers and determines the length of the longest non-decreasing subsequence. 8. and the loop stops. 10. 2 + 1 + 1. 42 Problem Write an algorithm that reads an array of n integers and ﬁnds the second smallest entry. if 123476 is the input. 9. x = 10 + 2 ∗ 3 = 16. n = 5. < X[m + n − 1]. Do this using algorithm R EVERSE A RRAY from example 23 a few times. 7. 10. the longest non-decreasing subsequence is 7. . x←0 while n = 0 comment: x accumulates truncated digit. a/b truncates the decimal part of the quotient. .

X[m] → X[m + 1] → . . . . 11 . → X[m − 1]. → X[m + n − 1] → X[0] → X[1] → . . 39 Reverse the array ﬁrst as n ← n/10 return (x) Then reverse each one of the two segments: X[m + n − 1] > X[m + n − 2] > . . . . > X[m] > X[m − 1] > . . > X[0].

10: F IBONACCI(n) if n = 0 then return (0) last ← 0 current ← 1 for i ← 2 to n ´ temp ← last + current last ← current current ← temp return (current) else .12 40 Here is a possible solution.6. Chapter 1 Algorithm 1.

” newEl and oldEl are the current and the previous elements. 41 Assume that the data is read from some ﬁle f .6. eof means “end of ﬁle. d is the length of the current run of non-decreasing numbers.11: L ARGEST I NCREASING S EQUENCE( f ) 1←d 1 ← dMax while not eof if newEl >= oldEl d ← d +1 ´ if d > dMax do then else then dMax ← d d←1 oldEl ← newEL if d > dMax then dMax ← d . dMax is the length of the longest run. Algorithm 1.

42 Here is one possible approach. X) comment: X is an array of length n.6. second ← x[0] minimum ← second for i ← 0 to n − 1 if minimum = second ´ if X[i] < minimum then then minimum ← X[i] else second ← X[i] if X[i] < minimum do second ← minimum then else minimum ← X[i] else if X[i] > minimum and X[i] < second then second ← X[i] .12: S ECOND S MALLEST(n. Algorithm 1.

The length of the partition is k and the summands are X[1] + · · · + X[k]. 12 . Initially k = n and X[1] = · · · = X[n] = 1. At the end we have X[1] = n and the rest are 0.. We store them in an array of length n + 1 with X[0] = 0. 43 We list partitions of n in alphabetic order and with decreasing summands.

13: PARTITIONS(n) s ← k−1 while not ((s = 1) or (X[s − 1] > X[s])) ¨ s ← s−1 X[s] ← X[s] + 1 sum ← 0 for i ← s + 1 to k ¨ sum ← sum + X[i] for ¨ i ← 1 to sum − 1 X[s + i] ← 1 k ← s + sum − 1 13 .6.Answers Algorithm 1.

13 .

then n3 − n is always divisible by 6. 4(hk) is divisible by 4. the product of an even integer and an odd integer is even. Facts previously learned help many a time when making a direct proof. so 2(c + d + 1) is an even integer. If 2a and 2b are even integers. Solution: We have n3 − n = (n − 1)n(n + 1).1 Proofs: Direct Proofs A direct proof is one that follows from the deﬁnitions. and so n3 − n is divisible by 6. 2(2no + 1) is an even integer. where k is an integer. the product of two odd integers is odd. 2( f + g) + 1 is an odd integer. • an odd integer is one of the form 2l + 1 where l is an integer. Since f + g is an integer. Since 2ml + l + n is an integer. 6 divides the quantity (n − 1)n(n + 1). Since hk is an integer. and exactly one of them which is divisible by 3. then 2a + 2b = 2(a + b). 2(2ml + m + l) + 1 is an odd integer. Now a + b is an integer. so 2(a + b) is an even integer. Since 2no + 1 is an integer. Now c + d + 1 is an integer. Let 2n be an even integer and let 2o + 1 be an odd integer. Let 2h 2k be even integers. the product of two even integers is divisible by 4. Prove that the sum of two even integers is even. Let 2 f be an even integer and 2g + 1 be an odd integer. Then 2 f + 2g + 1 = 2( f + g) + 1. Among three consecutive integers there is at least an even one. then 2c + 1 + 2d + 1 = 2(c + d + 1). Solution: We argue from the deﬁnitions. the sum of an even integer with and odd integer is odd. We assume as known that the sum of two integers is an integer.Chapter 2 Proof Methods 2. Since 2 and 3 do not have common factors. Then (2h)(2k) = 4(hk). 45 Example Prove that if n is an integer. If 2c + 1 and 2d + 1 are odd integers. 14 . the product of three consecutive integers. 44 Example Recall that • an even number is one of the form 2k. Let 2l + 1 and 2m + 1 be odd integers. Then (2n)(2o + 1) = 4no + 2n = 2(2no + 1). • an integer a is divisible by an integer b if there exists an integer c such that a = bc. the sum of two odd integers is even. Then (2l + 1)(2m + 1) = 4ml + 2l + 2m + 1 = 2(2ml + l + m) + 1.

where n > m. 33n+3 − 26n − 27 Solution: Let P(n) be the assertion “∃T ∈ N with 33n+3 − 26n − 27 = 169T . Thus squares leave remainder 0 or 1 when divided by 4 and hence their sum leave remainder 0. . Suppose that these steps must be followed in strict numerical order.). since we are taking the square roots of non-negative real numbers. 50 Corollary (Strong Induction) If a set A of positive integers contains the integer m and also contains n + 1 whenever it contains m + 1. 2. 15 . and then to the case following that. 2 yielding the result. We shall now give some examples of the use of induction. .2 Proofs: Mathematical Induction The Principle of Mathematical Induction is based on the following fairly intuitive observation. m + 2. Solution: An integer is either even (of the form 2k) or odd (of the form 2k + 1).” We will prove that P(1) is true and that P(n − 1) =⇒ P(n). n. we try to verify that some assertion P(n) concerning natural numbers is true for some base case k0 (usually k0 = 1). for n > 1. 48 Theorem Principle of Mathematical Induction If a set S of positive integers contains the integer 1. 2 √ √ Solution: First observe that x − y is a real number. suppose that we know how to perform the n-th task provided we have accomplished the n − 1-th task. then A contains all the positive integers greater than or equal to m. . which is divisible by 169.e. 51 Example Prove that the expression is a multiple of 169 for all natural numbers n. i. Thus if we are ever able to start the job (that is. 1. Then which reduces to 33n+3 − 26n − 27 = 27 · 33n − 26n − 27 = 27(33n − 26n − 1) + 676n 27 · 169N + 169 · 4n. For n = 1 we are asserting that 36 − 53 = 676 = 169 · 4 is divisible by 169. Suppose that we are to perform a task that involves a certain number of steps. The following versions of the Principle of Mathematical Induction should now be obvious. P(n − 1) means there is N ∈ N such that 33(n−1)+3 − 26(n − 1) − 27 = 169N. 49 Corollary If a set A of positive integers contains the integer m and also contains n + 1 whenever it contains n. which is evident.. 47 Example Prove that a sum of two squares of integers leaves remainder 0.Proofs: Mathematical Induction 15 46 Example Use the fact that the square of any real number is non-negative in order to prove the Arithmetic Mean-Geometric Mean Inequal- ity: ∀x ≥ 0. or 2. Finally. Expanding x+y √ √ x − 2 xy + y ≥ 0 =⇒ ≥ xy. We have (2k)2 (2k + 1)2 = = 4k2 . ∀y ≥ 0 x+y √ xy ≤ . then S = N. Then we try to settle whether information on P(n − 1) leads to favourable information on P(n). . then we should be able to ﬁnish it (because starting with the base case we go to the next case. 4(k2 + k) + 1. Now. 33n − 26n − 1 = 169N for some integer N. etc. and also contains the integer n + 1 whenever it contains the integer n. 1 or 2 when divided by 4. Thus in the Principle of Mathematical Induction. Since the square of any real number is greater than or equal to 0 we have √ √ ( x − y)2 ≥ 0. where n > m. The assertion is thus established by induction. then A contains all the positive integers greater than or equal to m. if we have a base case).

that is every number after the second one is the sum of the preceding two. 2n > n. 21. n+1 n n As k2 − 1 = (k2 − 1)(k2 + 1). Assume that P(n − 1) is true for n > 1. 1. as 20 > 0. . so the problem reduces to proving that 2|(k2n + 1). Consider now the quantity √ √ √ (1 + 2)2(n−1) − (1 − 2)2(n−1) = a 2 √ √ √ √ √ √ (1 + 2)2n + (1 − 2)2n = (1 + 2)2 (1 + 2)2n−2 + (1 − 2)2 (1 − 2)2n−2 . f1 = 1. assume that √ √ (1 + 2)2(n−1) + (1 − 2)2(n−1) = 2N for some integer N and that for some positive integer a. 53 Example Prove that is an even integer and that for some positive integer b. Now. 16 . Chapter 2 Solution: The assertion is true for n = 0.e. and so P(n) is true. 54 Example Prove that if k is odd. 2. n − 1 > 0 =⇒ n − 2 ≥ 0. . 8. k2 − 1 n Solution: The statement is evident for n = 1. Assume that 2n−1 > n − 1 for n > 1. . Thus the Fibonacci sequence then goes like 0. 2n = 2(2n−1 ) > 2(n − 1) = 2n − 2 = n + n − 2. Prove using the Principle of Mathematical Induction. 1. as k2 − 1 = (k − 1)(k + 1) is divisible by 8 for any odd natural number k because both n n+1 (k − 1) and (k + 1) are divisible by 2 and one of them is divisible by 4. for all integers n ≥ 1. i. 5. The assertion is thus established by induction. √ √ 12N + 2 2a 2 = 2(6N + 2a).. 3. an even integer. This is obviously true since k2n odd makes k2n + 1 even. 13. that for integer n ≥ 1. Now. and so. This establishes the validity of the n-th step from the preceding step and ﬁnishes the proof. n ≥ 1.16 52 Example Prove that 2n > n. fn+1 = fn + fn−1 . 2 fn−1 fn+1 = fn + (−1)n . . and let us prove that 2n+3 |k2 − 1. √ √ (1 + 2)2n + (1 − 2)2n √ √ √ (1 + 2)2n − (1 − 2)2n = b 2 √ √ √ √ √ Solution: We proceed by induction on n.” If n = 1. then we see that √ √ (1 + 2)2 + (1 − 2)2 = 6. This simpliﬁes to Using P(n − 1). Assume that 2n+2 |k2 − 1. then 2n+2 divides √ √ √ √ √ (1 + 2)2n − (1 − 2)2n = 3a 2 + 2 2(2N) = (3a + 4N) 2. and √ √ √ (1 + 2)2 − (1 − 2)2 = 4 2. Therefore P(1) is true. ∀n ∈ N. we have n + n − 2 ≥ n + 0 = n. for all natural numbers n. Let P(n) be the proposition: “(1 + 2)2n + (1 − 2)2n is even and (1 + 2)2n − (1 − 2)2n = b 2 for some b ∈ N. 55 Example The Fibonacci Numbers are given by f0 = 0. we see that 2n+2 divides (k2n − 1). the above simpliﬁes to an even integer and similarly √ √ √ √ (3 + 2 2)(1 + 2)2n−2 + (3 − 2 2)(1 − 2)2n−2 .

and so if the amounts n − 3. we assume that its negation is true and deduce incompatible statements from this. Shew that any quantity of pesos greater than or equal to 8 can be paid using the available coins. so it is impossible to write 2003 as the sum of squares. a quartering would make {n. 10 = 5 + 5. in trying to prove a premise. We will shew that we may also obtain solutions for 3x + 5y = k for k = n. Now 3x + 5y = n − 3 =⇒ 3(x + 1) + 5y = n. Solution: We use Strong Induction. so. But we know from example 47 that sums of squares do not leave remainder 3 upon division by 4.2 and 2. We will shew Figure 2. . 17 . . fn = fn−1 fn+1 − (−1)n .3 Proofs: Reductio ad Absurdum In this section we will see examples of proofs by contradiction. 3x2 + 5y2 = n − 1 =⇒ 3(x2 + 1) + 5y2 = n + 2.. Observe that 8 = 3 + 5. and that the assertion is true for n. n − 2. The statement of the problem now follows from Strong Induction.1: Example 56. Figure 2. and so the assertion follows by induction. n + 3. not necessarily of the same size. Figure 2. Figure 2. This means that fn fn+2 = = = = = fn ( fn+1 + fn ) 2 fn fn+1 + fn fn fn+1 + fn−1 fn+1 − (−1)n fn+1 ( fn + fn−1 ) + (−1)n+1 fn+1 fn+1 + (−1)n+1 . n − 2. 9 = 3 + 3 + 3. . now that n = 6 and n = 8 are achievable. 3x1 + 5y1 = n − 2 =⇒ 3(x1 + 1) + 5y1 = n + 1. for all n = 4.3. But this is easily seen from the ﬁgures 2. 7. n − 2 and n − 1. That is. Suppose n > 1.2: Example 56. Solution: 2003 leaves remainder 3 upon division by 4. 6. 58 Example Prove that 2003 is not the sum of two squares by proving that the sum of any two squares cannot leave remainder 3 upon division by 4. .1 that n = 4 is achievable. n + 9. we have 2 0 · 1 = f0 f1 = 12 − (1)1 = f1 − (1)1 . n + 6. that is 2 fn−1 fn+1 = fn + (−1)n . 17 and so the assertion is true for n = 1. and n − 1 pesos. 8. 57 Example In the country of SmallPesia coins only come in values of 3 and 5 pesos. 9. we can pay 8. . Solution: A quartering of a subsquare increases the number of squares by three (four new squares are gained but the original square is lost). n + 1 and n + 2. fn+2 = fn+1 + fn . Assume that we are able to pay n − 3.} also achievable. n − 1 can be paid so can n. . 56 Example Prove that a given square can be decomposed into n squares.3: Example 56. that is. n + 2. 2. that 3x + 5y = k has non-negative solutions for k = n − 3. and this ﬁnishes the proof. If n were achievable. and by the induction hypothesis. n + 1. or 10 pesos with the available coinage.Proofs: Reductio ad Absurdum Solution: For n = 1. 2 Using the Fibonacci recursion.

We therefore conclude that a ≤ b. . Squaring both sides we obtain 3481 ≥ 3500. . Observe that none of the primes on the list {p1 . This implies that 2 a−b > 0. The original assumption must be wrong. . which is clearly 10 10 √ 1 nonsense. .18 59 Example Shew. Solution: We need to assume for this proof that any integer greater than 1 is either a prime or a product of primes. p2 . . 64 Example If a. Thus it must be the case that 6 − 35 < . n. 2. Prove that the product (a1 − 1)(a2 − 2) · · · (an − n) is even. clearly greater than 1. b. . Solution: For this proof. an be an arbitrary permutation of the numbers 1. This is impossible. without using a calculator. with positive integers a. Our initial assumption that all the ak − k are odd is wrong. so one of these is even and hence the product is even. . 61 Example Prove that √ 2 is irrational. we will accept as fact that any positive integer greater than 1 can be factorised uniquely as the product of primes (up to the order of the factors). 62 Example Let a. . . Solution: Assume contrariwise that a > b. The following beautiful proof goes back to Euclid. Assume contrariwise that all the differences ak − k are odd. This yields 2b2 = a2 . . . S is an odd number of summands of odd integers adding to the even integer 0. a < b+ 63 Example (Euclid) Shew that there are inﬁnitely many prime numbers. √ a Assume that 2 = . pn } divides N. 2 Thus starting with the assumption that a > b we reach the incompatible conclusion that a < b. 10 √ √ √ 1 1 Solution: Assume that 6 − 35 ≥ . This is a contradiction. 2. prove that ax2 + bx + c = 0 does not have a rational number solution. where n is an odd number. b be real numbers and assume that for all numbers ε > 0 the following inequality holds: a < b + ε. Solution: First observe that the sum of an odd number of odd integers is odd. 18 . . . b. . Thus we have shewn that the assumption that any ﬁnite list of primes leads to the existence of a prime outside this list. Clearly S = (a1 − 1) + (a2 − 2) + · · · + (an − n) = 0. it is either a prime or divisible by a prime outside this list. Hence a−b ε= . p2 . since the ak ’s are a reordering of 1. Consider the number N = p1 p2 · · · pn + 1. . So b 2b2 has an odd numbers of primes in its factorisation and a2 has an even number of primes in its factorisation. since division by any of these primes leaves a remainder of 1. . Since N is larger than any of the primes on this list. Assume that {p1 . It is enough to prove that some difference ak − k is even. 10 60 Example Let a1 . . . a2 . that 6 − Chapter 2 √ 35 < 1 . Since the inequality a < b + ε holds for every ε > 0 in particular it holds for 2 a−b or a < b. Prove that a ≤ b. . This is a positive integer. Now both a2 and b2 have an even number of prime factors. c are odd integers. This implies that the number of primes is inﬁnite. n. . pn } is a list that exhausts all the primes. Then 6 − ≥ 35 or 59 ≥ 10 35.

. one can ﬁnd two of them. 66 Example Shew that amongst any seven distinct positive integers not exceeding 126. (odd.5: Example 69. (even. 55}. Any integer in the given set has a prime factorisation of the form 3a 7b 11c . . . b. so either p and q q are both odd. . . all the exponents of its prime factorisation must be even. which satisfy b < a ≤ 2b. even. 100. We may assume that p and q have no prime factors in common. odd. This apparently trivial principle is very powerful. (even. even. Take these two. 2 19 . {7. and obviously. odd. 13. 11} prove that there must be two whose product is a square. 4. then ap2 + bpq + cq2 is also odd and hence = 0.4: Example 68. This contradiction proves that the equation cannot have a rational root. . . .4 Proofs: Pigeonhole Principle The Pigeonhole Principle states that if n + 1 pigeons ﬂy to n holes. odd. even. . Thus in any group of 13 people. which add to 104. By the Pigeonhole Principle. 16. . Their product is a square. (odd. {49. . and if the average human head has two million hairs. . {52}. odd). odd). 61. there must be a pigeonhole containing at least two pigeons. 97}. Solution: For an integer to be a square. (even. two of the seven numbers must lie in one of the six sets. In a group of 9 such integers. Prove that there must be two distinct integers in A whose sum is 104. {3. . there must always be two whose distance is ≤ √ 2 . {31. {4. even). . 64. . odd). 68 Example Prove that if ﬁve points are taken on or inside a unit square. .Proofs: Pigeonhole Principle Solution: Suppose 19 p is a rational solution to the equation. 5. 32. since the sum of each corresponding exponent will be even. {10. Figure 2. . 126}. (odd. (odd. . . . Similarly if one of them is even and the other odd then either ap2 + bpq or bpq + cq2 is even and ap2 + bpq + cq2 is odd. Solution: Split the numbers {1. . . there are always two who have their birthday on the same month. . . even). there must be two with the same parity patterns in the exponents. 94}. 29. 100}. If both p and p were odd. 7. 62} and {63. c) has one of the following 8 parity patterns: (even. odd. . 4. {7. 6}. Figure 2. 67 Example Given any 9 integers whose prime factors lie in the set {3. . Now a p q 2 +b p q + c = 0 =⇒ ap2 + bpq + cq2 = 0. 8. . or one is odd and the other even. . 65 Example (Putnam 1978) Let A be any set of twenty integers chosen from the arithmetic progression 1. 30}. {15. 14}. even. odd). 2}. The Pigeonhole Principle is useful in proving existence problems. 2. that is. Solution: We partition the thirty four elements of this progression into nineteen groups {1}. 126} into the six sets {1. Since we are choosing twenty integers and we have nineteen sets. even). there are at least three people in NYC with the same number of hairs on their head. 3. we shew that something exists without actually identifying it concretely. 2. any such two will satisfy the stated inequality. by the Pigeonhole Principle there must be two integers that belong to one of the pairs. Now each triplet (a. say a and b. even).

and Two 2 1 )2 + ( 1 )2 = the longest distance there is. by the Pythagorean Theorem. 78 Problem Let a > 0. ( 2 . as in ﬁgure 2. Prove that the closed interval [s. the neighbors of a are e and b and so e + b = 1. then n divides (n − 1)!. c. 76 Problem The following 4 × 4 square has the property that for any of the 16 squares composing it. not necessarily distinct. a e i m b f j n c g k o d h l p 77 Problem Prove. 2s] contains a power of 2. w. 2 2 69 Example Fifty one points are placed on and inside a square of side 1. proving the statement. v. Õ a. · > . Use mathematical induction to prove that √ √ 1 + 4a + 1 a+ a+ a+··· + a < . b. Chips are drawn at random and without replacement from the urn. √ of the points must fall into one of the smaller squares. prime factors. b. and the sum of their digits is noted. 71 Problem Prove that there is no primes triple p. 73 Problem An urn has 900 chips. by choosing a special value for d above. that is. abcd ≤ 4 Then. √ 1 2 1 Form the circle with centre at the minisquare. numbered 100 through 999. 5.4. having at least three. Prove that p + q is a composite number. 79 Problem Use the AM-GM Inequality: ∀x ≥ 0. d we have x+y √ xy ≤ in order to prove that for all quadruplets of non-negative real numbers 2 √ a+b+c+d 4 . 72 Problem If x is an integer and 7 divides 3x + 2 prove that 7 also divides 15x2 − 11x − 14. by arguing by contradiction. p + 2. 5 2 7 Homework 70 Problem Prove that if n > 4 is composite. 75 Problem Let p < q be two consecutive odd primes. ∀y ≥ 0. At least three of the points must fall into one of these mini-squares. and radius of the diagonal of the square. Find the sum of all the numbers in the 16 squares.20 Chapter 2 Solution: Split the square into four congruent squares as shewn in ﬁgure 2. 2 where the left member contains an arbitrary number of radicals. p + 4 except for 3. c. Demonstrate that there must be three of them that ﬁt inside a circle of radius 1 . 20 . For example. deduce that √ u+v+w 3 uvw ≤ 3 for all non-negative real numbers u. 7 Solution: Divide the square into 25 congruent squares. that there are no integers a.5. d such that x4 + 2x2 + 2x + 2 = (x2 + ax + b)(x2 + cx + d). What is the smallest number of chips that must be drawn in order to guarantee that at least three of these digital sums be equal? 74 Problem Let s be a positive integer. the sum of the neighbors of that square is 1. 4.

83 Problem Prove by induction that if n non-parallel straight lines on the plane intersect at a common point. These cats have 16 kittens among themselves. 1 Why is it always eccentric widows who have multiple cats? 21 . .Homework 80 Problem Let a. What is the largest integer n for which one can say that at least one of the ﬁve cats has n kittens? 93 Problem No matter which ﬁfty ﬁve integers may be selected from {1. 84 Problem Demonstrate by induction that no matter how n straight lines divide the plane. 10 yellow marbles. 2. x · sin sin 2 2 1 · 2 + 2 · 22 + 3 · 23 + · · · + n · 2n = 2 + (n − 1)2n+1 . prove that a3 + b3 + c3 − 3abc = (a + b + c)(a2 + b2 + c2 − ab − bc − ca). Prove that if a. 12 white marbles. 89 Problem An urn contains 28 blue marbles. 0. and prove by induction. Prove that among the eight resulting sums (three columns. 88 Problem Prove. they divide the plane into 2n regions. Demonstrate that there is at least a pair of men who are facing each other. that sin n+1 x nx 2 . c are real numbers then 21 a2 + b2 + c2 − ab − bc − ca ≥ 0. 100}. b. . v. . w. and 8 magenta marbles. 2n+1 sin θ 86 Problem Demonstrate by induction that whenever the formula makes sense one has sin x + sin 2x + · · · + sin nx = 87 Problem Prove by induction that 2n > n for integer n ≥ 0. or otherwise. 85 Problem Demonstrate by induction that whenever the formula makes sense one has (cos θ )(cos 2θ ) · · · (cos 2n θ ) = sin 2n+1 θ . 91 Problem Forty nine women and ﬁfty one men sit around a round table. or 1. b. Use this to prove that 2001 is not the sum of three odd squares. How many marbles must be drawn from the urn in order to assure that there will be 15 marbles of the same color? 90 Problem The nine entries of a 3 × 3 grid are ﬁlled with −1. the sum of the ﬁrst n positive odd numbers. c be real numbers. By direct multiplication. 81 Problem Use the fact that any odd number is of the form 8k ± 1 or 8k ± 3 in order to give a direct proof that the square of any odd number leaves remainder 1 upon division by 8. Use the above two results to prove once again that √ u+v+w 3 uvw ≤ 3 for all non-negative real numbers u. 82 Problem Find. it is always possible to colour the regions produced in two colours so that any two adjacent regions have different colours. or two diagonals) there will always be two that add to the same number. three rows. by induction on n. prove that one must select some two that differ by 10. . 92 Problem An eccentric widow has ﬁve cats1 . 20 red marbles.

1 < a < b < n − 1. at least 3 chips will have the same sum. is divisible by the prime 2 and by at least two other primes dividing 2 2 76 The neighbors of a e n o d h is exactly the sum of all the elements of the table. whence d is even. three discs “3”. and so divisible p+q p+q by at least two primes. that is. p is odd. that is ∀a > 0. 2 ßÞ √ n radicands Let us prove P(1). Assume that s is strictly between two powers of 2: 2r−1 < s < 2r . Thus if 27 + 25 + 1 = 53 are drawn. The sums 1 and 27 only appear once (in 100 and 999). . and so ad + bc = 2 is even plus odd. with n = ab. Therefore ad is even. 22 . that 2 2 is. bd must be of opposite parity (one odd. . d are integers.22 Chapter 2 94 Problem (AHSME 1994) Label one disc “1”. Thus bd = 2. What is the minimum number of discs that must me drawn in order to guarantee drawing at least ten discs with the same label? 95 Problem Given any set of ten natural numbers between 1 and 99 inclusive. 73 There are 27 different sums. 4. 74 If s is itself a power of 2 then we are done. and so the interval [s. and since d + b + bc = 2. odd: a contradiction since 2 is not odd. To get this one. and so is an integer. p+q p+q 75 Since p and q are odd. Then s < 2r < 2s < 2r+1 . c. b. must be divisible by 3 and is different from 3 and hence not a prime. 15x2 − 11x − 14 = (3x + 2)(5x − 7) = 7a(5x − 7). n = a2 in which case 2 < a < 2a ≤ n − 1 and hence a and 2a are among the numbers {3. Since p and q are consecutive primes. ad + bc = 2. Furthermore. a power of 2. 77 We have x4 + 2x2 + 2x + 2 = = (x2 + ax + b)(x2 + cx + d) x4 + (a + c)x3 + (d + b + ac)x2 + (ad + bc)x + bd. 2 √ √ 1 + 4a + 1 a< 2 ⇐⇒ ⇐⇒ ⇐⇒ ⇐⇒ ⇐⇒ √ √ 2 a < 1 + 4a + 1 √ √ 2 a − 1 < 4a + 1 √ √ (2 a − 1)2 < ( 4a + 1)2 √ 4a − 4 a + 1 < 4a + 1 √ −2 a < 0. 71 If p > 3 and prime. Put these 1 + 2 + 3 + · · · + 50 = 1275 labeled discs in a box. If a > 1 4 √ √ 1 + 4a + 1 a< . So p + q = 2 . But p < q gives 2p < p + q < 2q and so p < < q. 78 Let P(n) : a+ Õ √ 1 + 4a + 1 a+ a+··· + a < . d + b + bc = 2. whence 7 divides 15x2 − 11x − 14. Assume a. prove that there are two disjoint nonempty subsets of the set with equal sums of their elements. . n − 1} or n is not a perfect square. let’s work backwards. 2s] contains 2r . ﬁfty discs “50”. each of the other 25 sums appears thrice. but still composite. . 72 We have 3x + 2 = 7a. meaning that both b and c are odd. the other even). Answers 70 Either n is a perfect square. the average of p and q lies between them. at least. . a + c = 2. Discs are then drawn from the box at random without replacement. . any number between them is composite. bc must be odd. . p + 2. p + 4. Hence the sum sought is 6. with a an integer. But then one of the three consecutive odd numbers p. we know that p + q is even. Since bd = 2. two discs “2”. . But then d + b must be odd.

From 23 √ √ 1 then trivially 2 a − 1 < 4a + 1. 81 We have (8k ± 3)2 = 64k2 ± 48k + 9 = 8(8k2 ± 6 + 1) + 1. Then a3 + b3 + c3 − 3abc = = = = (a + b)3 + c3 − 3ab(a + b) − 3abc (a + b + c)3 − 3(a + b)c(a + b + c) − 3ab(a + b + c) (a + b + c)((a + b + c)2 − 3ac − 3bc − 3ab) (a + b + c)(a2 + b2 + c2 − ab − bc − ca) a3 + b3 + c3 ≥ abc. Then 3 u+v+w+ ≤ 4 u+v+w 3 =⇒ =⇒ =⇒ =⇒ u + v + w 1/4 u + v + w ≤ 3 3 1−1/4 1/4 ≤ u + v + w (uvw) 3 u + v + w 3/4 (uvw)1/4 ≤ 3 u+v+w (uvw)1/3 ≤ . a sum of three odd squares must leave remainder 3 upon division by 8. 2 √ √ ( 4a + 1 + 1)2 = 4a + 2 4a + 1 + 2 proving the claim. 3 The desired inequality follows upon putting u = a3 . Now. use the identity x3 + y3 = (x + y)3 − 3xy(x + y) twice. proving that in all cases the remainder is 1 upon division by 8. Assume now 4 Õ a+ √ 1 + 4a + 1 a+ a+··· + a < =⇒ 2 ßÞ √ n radicands Õ a+ a+ ßÞ a+··· + a < √ Ö a+ √ 1 + 4a + 1 . 80 Since squares of real numbers are non-negative. it would leave remainder 3 = 1 + 1 + 1 upon division by 8. 2 n+1 radicands we see that it is enough to shew that Ö a+ But observe that √ √ 1 + 4a + 1 1 + 4a + 1 = . If a. If a ≤ that P(n) is true and let’s derive P(n + 1). ≤ 2 2 2 4 u+v+w . (8k ± 1)2 = 64k2 ± 16k + 1 = 8(8k2 ± 2) + 1. Thus if 2001 were a sum of three squares. b. v = b3 . Now. Thus P(1) is true. w = c3 . b = v. This gives 23 . 79 We have √ 4 abcd = Now let a = u. But 2001 leaves remainder 1 upon division by 8. 2 2 =⇒ √ 1 + 4a + 1 = 2 √ 1 + 4a + 1 a+ . 3 (uvw)1/4 4 u+v+w uvw 3 whence the required result follows.Answers all the steps are reversible and the last inequality is always true. c are non-negative then a + b + c ≥ 0 and also a2 + b2 + c2 − ab − bc − ca ≥ 0. we have (a − b)2 + (b − c)2 + (c − a)2 ≥ 0 ⇐⇒ ⇐⇒ 2a2 + 2b2 + 2c2 − 2ab − 2bc − 2ca ≥ 0 a2 + b2 + c2 − ab − bc − ca ≥ 0. c = w and d = √ √ ab · cd ≤ a+b c+d √ √ + ab + cd 2 = a+b+c+d . a contradiction to the assumption that it is a sum of three squares.

x · sin sin 2 2 sin 2n θ . that is. producing then 2n − 2 + 2 = 2n regions. 1 + 3 + · · · + (2n − 1). This line splits the plane into two regions. Consider now a new line added to the n − 1 lines. In region II we switch the colours. assume that (cos θ )(cos 2θ ) · · · (cos 2n−1 θ ) = Then (cos θ )(cos 2θ ) · · · (cos 2n θ ) = = = as wanted. 1+3+5 = 32 . 1 + 3 + 5 + 7 = 42 . We have already established this for n = 1. which we assume true. 86 The formula clearly holds for n = 1. that is. 2n+1 sin θ (sin nx ) 2 24 . We now have a coloring of the plane in the desired manner. 85 For n = 0 this is the identity sin 2θ = 2 sin θ cos θ . and divide the region between them into two more regions. Assume the statement is true for n − 1. 1+3 = 22 . A new line non-parallel to them but passing through a common point will lie between two of the old lines. and they are coloured in the desired manner by the induction hypothesis. say I and II. then they are coloured in the prescribed manner because we switched the colours in the second region. which we will prove by induction. We suspect that 1 + 3 + · · · + (2n − 1) = n2 . sin 2 sin n x (n − 1)x 2 . Assume Pn−1 . 83 The assertion is clear for n = 1 since a straight line divides the plane into two regions. the proposition that this is possible for n − 1 > 1 lines is true. that n − 1 non-parallel straight lines intersecting at a common point divide the plane into 2(n − 1) = 2n − 2 regions. Chapter 2 establishing the truth of Pn . Let Pn−1 be the proposition 1 + 3 + · · · + (2n − 3) = (n − 1)2 . 2n sin θ (cos θ )(cos 2θ ) · · · (cos 2n−1 θ )(cos 2n θ ) sin 2n θ (cos 2n θ ) 2n sin θ sin 2n+1 θ . Now 1 + 3 + · · · + (2n − 1) = = = = 1 + 3 + · · · + (2n − 3) + (2n − 1) (n − 1)2 + 2n − 1 n2 − 2n + 1 + 2n − 1 n2 . sin x + sin 2x + · · · + sin(n − 1)x + sin nx n sin 2 x (n−1)x + sin nx x · sin 2 sin 2 nx sin 2 (n−1)x + 2 sin nx cos nx x · sin 2 2 2 sin 2 (n−1)x nx x sin 2 + 2 cos 2 sin 2 (sin nx ) x 2 sin 2 nx cos x − sin x cos nx + 2 cos nx sin x sin 2 2 2 2 2 2 x sin 2 x x sin nx cos 2 + sin 2 cos nx 2 2 (sin nx ) x 2 sin 2 sin n+1 x 2 nx x · sin 2 . demonstrating the assertion. either the two regions lie completely in region I or completely in region II. We now do the following: in region I we leave the original coloration. Assume that sin x + sin 2x + · · · + sin(n − 1)x = Then sin x + sin 2x + · · · + sin nx = = = = = = = where we have used the sum identity sin(a ± b) = sin a cos b ± sin b cos a.24 82 We are required to ﬁnd Observe that 1 = 12 . If one lies in region I and the other in region II. Assume Pn−1 . 84 For n = 1 straight lines this is clear. For. So consider the plane split by n − 1 lines into regions and coloured as required.

a + 2n} into the n pairs and if n + 1 integers are chosen from this. forming a “diameter” on the table. a + n + 1}. From that group. . . there must be two that belong to the same group. and for n = 1 we have 21 = 2 > 1 so the assertion is true when n = 0 and n = 1. assume that 2n−1 > n − 1. a contradiction. there must be at least two different subsets that have the same sum. . 93 First observe that if we choose n + 1 integers from any string of 2n consecutive integers. . . 14 of the red and 14 of the blue marbles are drawn. {21. To each of these subsets we associate the sum of its elements. two of the eight sums must add up to the same. . . . 94 If we draw all the 1 + 2 + · · · + 9 = 45 labelled “1”. 3}. . . By the Pigeonhole Principle. 2. On either side of the diameter there must be an equal number of people. by the above observation (let n = 10). . 89 If all the magenta. The 415-th disc drawn will assure at least ten discs from a label. . . that is. 22. We would like to prove that we indeed have P(n + 1) : 1 · 2 + 2 · 22 + 3 · 23 + · · · + (n + 1) · 2n+1 = 2 + n2n+2 . Therefore. 2. . . . . . forty nine. Assume the statement is true for n. 88 For n = 1 we have 1 · 2 = 2 + (1 − 1)22 . But adding (n + 1)2n+1 to both sides of P(n) we obtain 1 · 2 + 2 · 22 + 3 · 23 + · · · + n · 2n + (n + 1)2n+1 = 2 + (n − 1)2n+1 + (n + 1)2n+1 = 2 + 2n2n+1 = 2 + n2n+2 . assume P(n) : 1 · 2 + 2 · 22 + 3 · 23 + · · · + n · 2n = 2 + (n − 1)2n+1 . . 91 Pick a pair of different sex facing one another. proving P(n + 1). 95 There are 210 − 1 = 1023 non-empty subsets that one can form with a given 10-element set. . −1. there must be two that differ by 10. that is. . 60}. So now group the one hundred integers as follows: {1. Assume the assertion is true for n − 1 > 0. {a + 2. −2.Answers 25 87 For n = 0 we have 20 = 1 > 0. 100}. 20}. {81. . 92 We have 16 5 = 4. and so the statement is true for n = 1. . . there will always be some two that differ by n. using the induction hypothesis and the fact that n − 1 ≥ 1. This is because we can pair the 2n consecutive integers {a + 1. a + 2. so there is at least one cat who has four kittens. we have drawn 45 + 9 · 41 = 414 discs. . . 42. Examine 2n = 2(2n−1 ) = 2n−1 + 2n−1 > n − 1 + n − 1 ≥ n − 1 + 1 = n. . . 62. . then in among these 8 + 10 + 12 + 14 + 14 = 58 there are no 15 marbles of the same color. “50”. we must perforce choose eleven from some group. 82. {61. that is. all the yellow. {a + n. If all the men were on one side of the diameter then we would have a total of 49 + 1 = 50. that is. each one a number in {−3. . 1. all the white. a + 2n}. {a + 1. Thus we need 59 marbles in order to insure that there will be 15 marbles of the same color. 40}. 80} and If we select ﬁfty ﬁve integers. The maximum value that any such sum can achieve is 90 + 91 + · · · + 99 = 945 < 1023. . . a + 3. 90 There are seven possible sums. . 25 . 0. “9” and any nine from each of the discs “10”. . {41. . a + n + 2}.

( false ) There exists inﬁnitely many primes which are the sum of a square and 1.Chapter 3 Logic. Otis! This sentence is false. ∧ (and or conjunction) ¬ (not or negation). if known: 72 = 49. and Boolean Algebra 3. ( false ) If p is a prime then p is odd. 97 Example The following are boolean propositions and their values. The ∨ = or is inclusive. Whether the statement is obviously true or false does not enter in the deﬁnition. They are listed in order of operator precedence and their evaluation rules are given in Table 3. Whenever I shampoo my camel. Sit on a potato pan. (unknown) 98 Example The following are not boolean propositions. ( true ) Every even integer greater than 6 is the sum of two distinct primes. Its output is either true or false y ← x. 26 . One only needs to know that its certainty can be established. or b is true. meaning that if a ∨ b then either a is true. ( true ) 5 > 6. ∨ (or or disjunction) =⇒ (implies) = (equals) ¬ has right-to-left associativity. ( true ) I am the Pope. since it is impossible to assign a true or false value to them. 99 Deﬁnition A boolean operator is a character used on boolean propositions. ( false ) Every prime that leaves remainder 1 when divided by 4 is the sum of two squares. We will consider the following boolean operators in these notes. Sets. all other operators listed have left-to-right associativity. (unknown) There is a dog. (unknown) There is a G-d.1. or both a and b are true.1 Logic 96 Deﬁnition A boolean proposition is a statement which can be characterised as either true or false .

b > 0. b. I will go jogging. b =⇒ ¬c: If it is snowing.Logic a F F T T b F T F T (¬a) T T F F (a ∧ b) F F F T (a ∨ b) F T T T (a =⇒ b) T T F T (a = b) T F F T 27 Table 3. but I will not go jogging. c > 0.1: Evaluation Rules 100 Example Consider the propositions: • a : I will eat my socks. 102 Example a =⇒ b =⇒ c is equivalent to (a =⇒ b) =⇒ c upon using the associativity rules. Algorithm 3. Solution: First we must have a > 0. 103 Example a ∧ ¬b =⇒ c is equivalent to (a ∧ ¬b) =⇒ c by the precedence rules. I will eat my socks. I will not go jogging. • b : It is snowing. 101 Example ¬a =⇒ a ∨ b is equivalent to (¬a) =⇒ (a ∨ b) upon using the precedence rules.1: I S I TAT RIANGLE((a. (b ∨ ¬b) =⇒ c: Whether or not it is snowing. The sentences below are represented by means of logical operators. c + a > b. Sides of length a. • c : I will go jogging. b. decides whether they form the sides of a triangle.1. c form a triangle if and only they satisfy the triangle inequalities:: a + b > c. b =⇒ (a ∧ ¬c): If it is snowing. 104 Example Write a code fragment that accepts three numbers. b + c > a. c)) if ((a > 0) and (b > 0) and (c > 0) and ((a + b > c) and (b + c > a) and (c + a > b)) then istriangle ← true else istriangle ← false return (istriangle) .

the truth table will have 2n lines. The truth table is in Table 3. Solution: Since there are three variables. the truth table will have 23 = 8 lines. Notice that by the precedence rules the given proposition is equivalent to a ∨ (¬b ∧ c). 27 . If proposition P is equivalent to proposition Q we write P = Q.2. since ∧ has higher precedence than ∨. 106 Example Construct the truth table of the proposition a ∨ ¬b ∧ c. If there are n variables. 107 Deﬁnition Two propositions are said to be equivalent if they have the same truth table. 105 Deﬁnition A truth table is a table assigning all possible combinations of T or F to the variables in a proposition.

” 28 . Translate into symbols: either p or q is true. 112 Deﬁnition A predicate is a sentence containing variables. The required expression is thus (p ∧ ¬q) ∨ (¬p ∧ q). if p is true then q must be false. Table 3. Solution: Using the De Morgan Rules and double negation: ¬(A ∨ ¬B) = ¬A ∧ ¬(¬B) = ¬A ∧ B. 108 Theorem (Double Negation) ¬(¬a) = a. which we represent as p ∧ ¬q.28 a F F F F T T T T b F F T T F F T T c F T F T F T F T (¬b) T T F F T T F F (¬b ∧ c) F T F F F T F F a ∨ (¬b ∧ c) F T F F T T T T Chapter 3 Table 3. Proof: From the truth table 3. proving the assertion.2: Example 106. Solution: By the conditions of the problem.3: Theorem 108. Similarly if q is true. but not both simultaneously.” 114 Deﬁnition (Universal Quantiﬁer) We use the symbol ∀ to mean “for all.5 proves that ¬(a ∧ b) = ¬a ∨ ¬b. p must be false and we must have ¬p ∧ q. Proof: Truth table 3. 113 Deﬁnition (Existential Quantiﬁer) We use the symbol ∃ to mean “there exists. whose truth or falsity depends on the values assigned to the variables.4 proves that ¬(a ∨ b) = ¬a ∧ ¬b and truth table 3.4: ¬(a ∨ b) = ¬a ∧ ¬b . 111 Example Let p and q be propositions.3 the entries for a and ¬(¬a) produce the same output.5: ¬(a ∧ b) = ¬a ∨ ¬b. u 109 Theorem (De Morgan’s Rules) ¬(a ∨ b) = ¬a ∧ ¬b and ¬(a ∧ b) = ¬a ∨ ¬b. a F F T T b F T F T (a ∨ b) F T T T ¬(a ∨ b) T F F F (¬a) T T F F (¬b) T F T F (¬a ∧ ¬b) T F F F a F F T T b F T F T (a ∧ b) F F F T ¬(a ∧ b) T T T F (¬a) T T F F (¬b) T F T F (¬a ∨ ¬b) T T T F Table 3. a F T (¬a) T F (¬(¬a)) F T Table 3. u 110 Example Negate A ∨ ¬B.

We use the boldface letters N to denote the natural numbers (nonnegative integers) and Z to denote the integers. 115 Example Write the negation of (∀n ∈ N)(∃x ∈]0. then we say that A is a subset of B and we write this as A ⊆ B (some authors use the notation A ⊂ B). we simply list all the subsets of {a. then we say that x belongs to S and we write this as x ∈ S. +∞[)(nx ≥ 1). +∞[)(nx < 1). 116 Example Find all the subsets of {a. d} 118 Theorem A ﬁnite n-element set has 2n subsets. d} {b. This gives S1 S2 S3 S4 S5 S6 S7 S8 = = = = = = = = ∅ {a} {b} {c} {a. c. a} {a. then A = {1. b. = = = = = = = = ∅ {a} {b} {c} {a. d} either contains d or it does not. d} {a. c} Solution: The idea is the following. a. which we write as A ⊆ B. If ∃x ∈ A such that x ∈ B. For example if S = {n ∈ N : n is the square of an integer }. If S is a set and the element x is in the set. c} {c. d} {c. b. d}. b. Since the subsets of {a. 29 Solution: Since ¬(∀n ∈ N) = (∃n ∈ N). d} {a. b. b. that is. Assume every set with n − 1 elements has 2n−1 subsets. b. ¬(∃x ∈]0. If a set A is totally contained in another set B. Let B be a set with n elements. d} {c. b. the number of elements that A has. then A is not a subset of B. 16} is a subset of S. and so B has a total of 2n−1 + 2n−1 = 2n subsets. 4. We denote by card (A) the cardinality of A. 9. u 119 Deﬁnition The union of two sets A and B. a subset of {a. +∞[) and ¬(nx < 1) = (nx ≥ 1). We use the result of example 116. c} S9 S10 S11 S12 S13 S14 S15 S16 = = = = = = = = {d} {a. b. d} {b. is the set A ∪ B = {x : (x ∈ A) ∨ (x ∈ B)}. c} and then to each one of them we add d. 3. Clearly a set A with n = 1 elements has 21 = 2 subsets: ∅ and A itself. c. Proof: We use induction and the idea of example 117.2 Sets We will consider a set naively as a collection of objects called elements. If x ∈ B then B \ {x} is a set with n − 1 elements and so by the induction hypothesis it has 2n−1 subsets. +∞[) = (∀x ∈]0. b} {b. This is a subset of B. c} {c. c}. If x does not belong to S we write x ∈ S. c} do not contain d. Two sets A and B are equal if A ⊆ B and B ⊆ A. Now. c. the required statement is (∃n ∈ N)(∀x ∈]0. if S = {squares of integers}. Solution: They are S1 S2 S3 S4 S5 S6 S7 S8 117 Example Find all the subsets of {a. The boldface letters R and C shall respectively denote the real numbers and the complex numbers. then 4 ∈ S but 2 ∈ S. For each subset S ⊆ B \ {x} we form the new subset S ∪ {x}. b. c. 29 . a} {a. For example.Sets Observe that ¬∀ = ∃ and ¬∃ = ∀. b} {b. There are 2n−1 such new subsets.

Then x ∈ A ∪ B. The difference of two sets A and B. 9} be the universal set of the decimal digits and let A = {0.2) (3. 6.2. Thus x ∈ A ∧ x ∈ B. Therefore (A ∪ B) ⊆ A ∩ B. Solution: Let x ∈ (A ∪ B).4: A 120 Deﬁnition Let A ⊆ X. Since we have shown that the two sets contain each other. The complement A represents the event that A does not occur. This is the same as x ∈ A ∩ B. Observe that We also have the De Morgan Laws: if A and B share the same universal set. 6. 9} is the set of odd digits. Then A = {1. Solution: We have x ∈ A \ (B ∪C) ⇐⇒ ⇐⇒ ⇐⇒ ⇐⇒ ⇐⇒ x ∈ A ∧ x ∈ (B ∨C) (x ∈ A) ∧ ((x ∈ B) ∧ (x ∈ C)) (x ∈ A ∧ x ∈ B) ∧ (x ∈ A ∧ x ∈ C) (x ∈ A \ B) ∧ (x ∈ A \C) x ∈ (A \ B) ∩ (A \C) 30 . We represent A pictorially as in ﬁgure 3. Usually we assume that A is a subset of some universal set U which is tacitly understood. 4.4. 4.” See ﬁgure 3. 7.1.3: A \ B Figure 3.1) We will now prove one of the De Morgan’s Rules. (3. Hence A ∩ B ⊆ (A ∪ B).3. 122 Example Prove that (A ∪ B) = A ∩ B. (A ∩ B) = A ∪ B. let x ∈ A ∩ B. 3. The complement of A with respect to X is A = X \ A. (3. The intersection of two sets A and B. 5. it must be the case that they are equal. is A ∩ B = {x : (x ∈ A) ∧ (x ∈ B)}. is A \ B = {x : (x ∈ A) ∧ (x ∈ B)}. This is read “A set minus B. 8} ⊂ U be the set of even digits. 2.30 This is read “A union B. 7. 123 Example Prove that A \ (B ∪C) = (A \ B) ∩ (A \C).” See ﬁgure 3.2: A ∩ B Figure 3. This means that x ∈ A ∧ x ∈ B or what is the same x ∈ A ∪ B. that is. 1. x ∈ A ∧ x ∈ B. This is read “A intersection B. Chapter 3 A A A B A B A B Figure 3.3) A ∩ A = ∅. But this last statement asserts that x ∈ (A ∪ B). Then x ∈ A ∧ x ∈ B. 8. Now. 121 Example Let U = {0. Observe that A is all that which is outside A. we have (A ∪ B) = A ∩ B.1: A ∪ B Figure 3. 3. 5. 2.” See ﬁgure 3.

Boolean Algebras and Boolean Operations 124 Example Shew how to write the union A ∪ B ∪C as a disjoint union of sets. comment: Y is an array of length m. . Write an algorithm to determine {x1 . Solution: Algorithm 3. . x2 . . B \ A. .2.Y ) comment: X is an array of length n. ym }. 31 Solution: The sets A. X. y2 . n1 ← 0 m1 ← 0 common ← 0 while (n1 = n) and (m1 = m) if X[n1 + 1] < Y [m1 + 1] then n1 ← n1 + 1 else if X[n1 + 1] > Y [m1 + 1] then m1 ← m1 + 1 do ´ n1 ← n1 + 1 else m1 ← m1 + 1 common ← common + 1 .1: I NTERSECTION(n. .C \ (A ∪ B) are clearly disjoint and A ∪ B ∪C = A ∪ (B \ A) ∪ (C \ (A ∪ B)). 125 Example Let x1 < x2 < · · · < xn and y1 < y2 < · · · < ym be two strictly increasing sequences of integers. . . . xn } ∩ {y1 . m.

+ = ∪. 30}. 5. the set of positive divisors of 30. Under these A operations X becomes a boolean algebra. 129 Example Let X = {1. 1 = T . A + A = 1 10. T } constitute a boolean algebra. + = ∨. and a boolean algebra.3 Boolean Algebras and Boolean Operations 126 Deﬁnition A boolean algebra consists of a set X with at least two different elements 0 and 1. AA = 0 127 Example If we regard 0 = F. A + (BC) = (A + B)(A +C) (distributive law) 7. 3. 3. and A = . and = ¬. · = ∧. · = ∩. A(B +C) = AB + AC (distributive law) 6. 31 . 30 · as the greatest common divisor of two elements. 6. two binary operations + (addition) and · (multiplication). A1 = A (1 is the multiplicative identity) 9. The additive identity is 1 and the multiplicative identity is 30. then the logic operations over {F. A + (B +C) = (A + B) +C (associativity of addition) 4. A + B = B + A (commutativity of addition) 2. A + 0 = A (0 is the additive identity) 8. AB = BA (commutativity of multiplication) 3. 2. = . We deﬁne + as the least common multiple of two elements. 15. 1 = U (the universal set). and a unary operation the product A · B. then the set operations over the subsets of U constitute 128 Example If we regard 0 = ∅. A(BC) = (AB)C (associativity of multiplication) 5. 10. (We use the juxtaposition AB to denote 1.) (called complementation) satisfying the following axioms.

Also.6: Evaluation Rules The operations of complementation. 0 = 0 + 0. 133 Theorem (Uniqueness of the Complement) If AB = 0 and A + B = 1 then B = A. Similarly. Thus u 134 Theorem (Involution Law) A = A A = A1 = A(A + B) = A · A + AB = AB. u A · 0 = A(A · A) = (AA)A = AA = 0. addition and multiplication act on 0 and 1 as shewn in table 3. Also. Proof: We have A + 1 = A + (A + A) = (A + A) + A = A + A = 1. The following properties are immediate. Proof: By axioms 9 and 10. 1 = 1 · 1. 1 · 1 = 0 and thus 1 = 1 · 1 = 0. Proof: Since 0 is the additive identity. 0 + 0 = 1 and thus 0 = 0 + 0 = 1. u 32 . But by axiom 9. B = BA = AB = A.6. Similarly A = A1 = A(A + A) = AA + A · A = AA + 0 = AA. u 132 Theorem (Domination Laws) A + 1 = 1 and A · 0 = 0.32 A 0 0 1 1 B 0 1 0 1 A 1 1 0 0 A+B 0 1 1 1 AB 0 0 0 1 Chapter 3 Table 3. Proof: We have B = B1 = B(A + A) = BA + BA = 0 + BA = BA. u 131 Theorem (Idempotent Laws) A + A = A and AA = A Proof: We have A = A + 0 = A + A · A = (A + A)(A + A) = (A + A)(1) = A + A. 130 Theorem 0 = 1 and 1 = 0. By uniqueness of the complement we must have A = A. since 1 is the multiplicative identity. we have the identities 1 = A + A and A · A = 0. But by axiom 10.

33 . write the variable if the variable input is 0 or write the complement of the variable if the variable input is 1. add all such terms. (A + B)A · B = AA · B + BA · B = 0 + 0 = 0.Sum of Products and Products of Sums 135 Theorem (De Morgan’s Laws) A + B = A · B and A · B = A + B. This can be done by either ﬁnding a sum of products (SOP) or a product of sums (POS) for the table. u 138 Theorem (Absorption Laws) A + AB = A and A(A + B) = A. A + AB = (A + A)(A + B) = 1(A + B) = A + B. Proof: Factoring AB + AB = A(B + B) = A(1) = A. Proof: Factoring and using the domination laws: A + AB = A(1 + B) = A1 = A. for each such row. To ﬁnd a sum of products from a truth table: identify the rows having output 1. Using the distributive law. Thus A · B is the complement of A + B and so we must have A · B = A + B. for each such row. Proof: Multiplying A(A + B) = AA + AB = 0 + AB = AB. To obtain the other De Morgan Law put A instead of A and B instead of B in the law just derived and use the involution law: A + B = A · B = AB. write the variable if the variable input is 1 or write the complement of the variable if the variable input is 0. Taking complements once again we have A + B = AB =⇒ A + B = AB. u 137 Theorem A(A + B) = AB and A + AB = A + B. 33 Proof: Observe that and (A + B) + A · B = (A + B + A)(A + B + B) = (B + 1)(A + 1) = 1. Expanding and using the identity just derived: A(A + B) = AA + AB = A + AB = A. u 136 Theorem AB + AB = A. we would like to ﬁnd a function whose output is that of the table. then add the variables forming a sum multiply all such sums. then multiply the variables forming a term. To ﬁnd a product of sums from a truth table: identify the rows having output 0. u 3.4 Sum of Products and Products of Sums Given a truth table in some boolean variables.

5 Logic Puzzles The boolean algebra identities from the preceding section may help to solve some logic puzzles.C = 0. The thieves escaped in a car that was waiting for them. (iii) A = 1. B = 0.C = 1. 143 Example Brown.C = 0. where we have used the fact that AB + B = A + B and the De Morgan laws. so we form the term A + B +C. so we form the term ABC. and (iv) A = B = C = 1. The required SOP is Z = (A)(B)(C) + ABC + ABC + ABC. Solution: We have W XY +W XZ +Y + Z = = = W X(Y + Z) +Y + Z W X +Y + Z W X +Y · Z.C = 1. (ii) A = 0. B = 0. B = 1. The output (Z) 0’s occur on the rows (i) A = 0. 141 Example Convert the following SOP to a POS: AB +CD. 3. so we form the term ABC. B = 0. B = 1. so we form the term A + B +C. B = 1. giving the term A + B +C. giving the term ABC. Chapter 3 A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 Z 1 0 1 0 0 0 1 1 Solution: The output (Z) 1’s occur on the rows (i) A = 0. (ii) A = 0.C = 0. or transform a SOP into a POS or viceversa. Johns and Landau are charged with bank robbery. 140 Example Convert the following POS to a SOP: (A + BC)(A + BD). each one of them only indicated correctly either the make of the car or only its colour. Solution: (A + BC)(A + BD) = = = AA + ABD + ABC + BCBD A + ABD + ABC + BCD A + BCD. Johns stated that it had been a black Chevrolet.C = 1. and (iv) A = 1. Solution: AB +CD = = (AB +C)(AB + D) (A +C)(B +C)(A + D)(B + D). The required POS is Z = (A + B +C)(A + B +C)(A + B +C)(A + B +C). (iii) A = 1.34 139 Example Find a SOP and a POS for Z. so we form the term A + B +C. and Landau said that it had been a Ford Granada and by no means blue.C = 0. It turned out that wishing to confuse the Court. 142 Example Write W XY +W XZ +Y + Z as a sum of two products. so we form the term (A)(B)(C). What colour was the car and of what make? Solution: Consider the sentences 34 . At the inquest Brown stated that the criminals had escaped in a blue Buick. B = 0. Using the axioms of a boolean algebra and the aforementioned theorems we may simplify a given boolean expression.

Mimi. Then there ¸ was a ring from .” “That’s all. with proof. they replied: Margie: “April won. e = = = = = = April was ﬁrst April was second Mimi was second Margie was second Rachel was third Rachel was last “Maigret here . Now ¸ everything was clear to him. the murderer. 35 . and Mimi was last. we obtain (A ·C · A) + (A ·C · E) + (A · D · A) + (A · D · E) + (B ·C · A) + (B ·C · E) + (B · D · A) + (B · D · E). who won the race? Solution: Consider the sentences A B C D E F Since each of the girls gave one true statement we have that (A +C)(B + E)(F + D) = 1. From the hypothesis that each of the criminals gave one correct answer. Solution: Represent the following sentences as: A B C D = = = = Francois was drunk. 144 Example Margie. and Rachel ran a race. He knew that when Francois was sober he never lied. . April. then either Etienne is the murderer or Francois is lying. Multiplying this out ABF + ABD + AEF + AED +CBF +CBD +CEF +CED = 1. Find. it follows that Brown’s declaration A + B is true.” If each of the girls made one and only one true statement. Margie was second. and so the criminals escaped in a black Buick. then either Etienne is the murderer or Francois is ¸ ¸ lying. and Landau’s declaration A + E is true. That’s enough!” The commissar replaced the receiver. The inspectors have reported. Now. ¸ Etienne is the murderer. except the ﬁfth. thanks. Mimi was second. Asked how they made out. Similarly. Upon multiplying this out.” April: “Rachel was last.” Mimi: “April was second and Rachel was third. is false. it follows that each of the summands. Francois is telling a lie. ¸ the murder took place after midnight. Torrence thinks that if Francois was drunk. Justin is of the opinion that either Etienne is the murderer or Francois was not drunk and the murder occurred after midnight. Rachel was third. Inspector ¸ Lucas asked me to tell you that if the murder had occurred after midnight. . Johns’s declaration C + D is true. 145 Example Having returned home. AB = EF = BC = CD = 0 so the only surviving term is AED and so April was ﬁrst. . Margie was second.Logic Puzzles A B C D E = = = = = the car is blue the car is a Buick the car is black the car is a Chevrolet the car is a Ford Granada 35 Since each of the criminals gave one correct answer. Any news?” “Yes Chief. It now follows that (A + B) · (C + D) · (A + E) is true. Thus B ·C · A is true. Maigret rang his ofﬁce on quai des Orf` vres.

But Maigret knows that AC = 0. 151 Problem Obtain a sum of products for the truth table A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 Z 1 1 1 1 0 0 0 0 152 Problem Use the Inclusion-Exclusion Principle to determine how many integers in the set {1. we see that the output of the product of the following sentences must be 1: (A + B +C)(B + AD)(D + B +C). i. Answers 146 p F F T T q F T F T p =⇒ q T T F T (p =⇒ q) ∧ q F T F T 36 . either Etienne is the murderer. 148 Problem Explain whether the following assertion is true and negate it without using the negation symbol ¬: ¡ ∀n ∈ N ∃m ∈ N n > 3 =⇒ (n + 7)2 > 49 + m 149 Problem Explain whether the following assertion is true and negate it without using the negation symbol ¬: ¡ ∀n ∈ N ∃m ∈ N n2 > 4n =⇒ 2n > 2m + 10 150 Problem Prove by means of set inclusion that (A ∪ B) ∩C = (A ∩C) ∪ (B ∩C). 147 Problem By means of a truth table.e. B + AD. Francois was not drunk and the murder ¸ ¸ took place after midnight. . D =⇒ (B +C). . Etienne is the murderer. . decide whether (p∧q)∨(¬p) = p∨(¬p). you want to compare the outputs of (p∧q)∨(¬p) and p ∨ (¬p).. Chapter 3 So. After multiplying the above product and simplifying. we obtain B +CAD.36 We then have A =⇒ (B +C). Homework 146 Problem Construct the truth table for (p =⇒ q) ∧ q. 2. or the following events occurred simultaneously: Francois lied. . 200} are neither divisible by 3 nor 7 but are divisible by 11. thus it follows that E = 1. Using the identity X =⇒ Y = X +Y. That is.

Answers

147 The desired truth table is p F F T T 148 The assertion is true. We have Hence, taking m = n2 + 14n − 1 for instance (or any smaller number), will make the assertion true. 150 We have, x ∈ (A ∪ B) ∩C ⇐⇒ ⇐⇒ ⇐⇒ ⇐⇒ ⇐⇒ x ∈ (A ∪ B) ∧ x ∈ C (x ∈ A ∨ x ∈ B) ∧ x ∈ C (x ∈ A ∧ x ∈ C) ∨ (x ∈ B ∧ x ∈ C) (x ∈ A ∩C) ∨ (x ∈ B ∩C) x ∈ (A ∩C) ∪ (B ∩C), (n + 7)2 > 49 + m ⇐⇒ n2 + 14n > m. q F T F T p∧q F F F T ¬p T T F F p ∨ ¬p T T T T (p ∧ q) ∨ (¬p) T T F T

37

which establishes the equality. 151

A · B ·C + A · B ·C + A · B ·C + A · B ·C 152 10

37

Chapter

4

2Z = {. . . , −6, −4, −2, 0, 2, 4, 6, . . .} = 0

**Relations and Functions
**

4.1 Partitions and Equivalence Relations

153 Deﬁnition Let S = ∅ be a set. A partition of S is a collection of non-empty, pairwise disjoint subsets of S whose union is S . 154 Example Let

be the set of even integers and let 2Z + 1 = {. . . , −5, −3, −1, 1, 3, 5, . . .} = 1 be the set of odd integers. Then and so {2Z, 2Z + 1} is a partition of Z.

155 Example Let

(2Z) ∪ (2Z + 1) = Z, (2Z) ∩ (2Z + 1) = ∅,

be the integral multiples of 3, let

3Z = {. . . − 9, , −6, −3, 0, 3, 6, 9, . . .} = 0 3Z + 1 = {. . . , −8, −5, −2, 1, 4, 7, . . .} = 1

be the integers leaving remainder 1 upon division by 3, and let 3Z + 2 = {. . . , −7, −4, −1, 2, 5, 8, . . .} = 2 be integers leaving remainder 2 upon division by 3. Then (3Z) ∪ (3Z + 1) ∪ (3Z + 2) = Z,

and so {3Z, 3Z + 1, 3Z + 2} is a partition of Z.

(3Z) ∩ (3Z + 1) = ∅, (3Z) ∩ (3Z + 2) = ∅, (3Z + 1) ∩ (3Z + 2) = ∅,

Notice that 0 and 1 do not mean the same in examples 154 and 155. Whenever we make use of this notation, the integral

divisor must be made explicit.

156 Example Observe

R = (Q) ∪ (R \ Q), ∅ = (Q) ∩ (R \ Q), which means that the real numbers can be partitioned into the rational and irrational numbers.

157 Deﬁnition Let A, B be sets. A relation R is a subset of the Cartesian product A × B. We write the fact that (x, y) ∈ R as x ∼ y. 158 Deﬁnition Let A be a set and R be a relation on A × A. Then R is said to be

• symmetric if (∀(x, y) ∈ A2 ), x ∼ y =⇒ y ∼ x,

• reﬂexive if (∀x ∈ A), x ∼ x,

38

**Partitions and Equivalence Relations
**

• anti-symmetric if (∀(x, y) ∈ A2 ), (x ∼ y) and (y ∼ x) =⇒ x = y, • transitive if (∀(x, y, z) ∈ A3 ), (x ∼ y) and (y ∼ z) =⇒ (x ∼ z).

39

A relation R which is reﬂexive, symmetric and transitive is called an equivalence relation on A. A relation R which is reﬂexive, anti-symmetric and transitive is called a partial order on A.

159 Example Let S ={All Human Beings}, and deﬁne ∼ on S as a ∼ b if and only if a and b have the same mother. Then a ∼ a since any

human a has the same mother as himself. Similarly, a ∼ b =⇒ b ∼ a and (a ∼ b) and (b ∼ c) =⇒ (a ∼ c). Therefore ∼ is an equivalence relation.

relation on L.

160 Example Let L be the set of all lines on the plane and write l1 ∼ l2 if l1 ||l2 (the line l1 is parallel to the line l2 ). Then ∼ is an equivalence

161 Example Let X be a collection of sets. Write A ∼ B if A ⊆ B. Then ∼ is a partial order on X. 162 Example For (a, b) ∈ R2 deﬁne

Determine, with proof, whether ∼ is reﬂexive, symmetric, and/or transitive. Is ∼ an equivalence relation? Solution: Since 02 + 02 2, we have 0 0 and so ∼ is not reﬂexive. Now, a∼b ⇔ ⇔ ⇔ a2 + b2 b2 + a2 b ∼ a, 1 since 02 + 12 2. Thus the relation is not transitive.

a ∼ b ⇔ a2 + b2 > 2.

so ∼ is symmetric. Also 0 ∼ 3 since 02 + 32 > 2 and 3 ∼ 1 since 32 + 12 > 2. But 0 The relation, therefore, is not an equivalence relation.

163 Example For (a, b) ∈ (Q∗ )2 deﬁne the relation ∼ as follows: a ∼ b ⇔ a ∈ Z. Determine whether this relation is reﬂexive, symmetric, b

and/or transitive.

2 Solution: a ∼ a since a = 1 ∈ Z, and so the relation is reﬂexive. The relation is not symmetric. For 2 ∼ 1 since 1 ∈ Z but 1 a a The relation is transitive. For assume a ∼ b and b ∼ c. Then there exist (m, n) ∈ Z2 such that b = m, b = n. This gives c

2 since

1 2

∈ Z.

a a b = · = mn ∈ Z, c b c and so a ∼ c.

164 Example Give an example of a relation on Z∗ which is reﬂexive, but is neither symmetric nor transitive.

a2 +a b ∈ Z. Then clearly if a 2 +5 other hand, the relation is not symmetric, since 5 ∼ 2 as 5 2 = 15 ∈ Z but 2 ∼ 52 +5 32 +3 52 +5 12. 3 ∈ Z =⇒ 5 ∼ 3 and 12 ∈ Z =⇒ 3 ∼ 12 but 12 ∈ Z and so 5

Solution: Here is one possible example: put a ∼ b ⇔

∈ Z∗ we have a ∼ a since 5, as

2 +2 5

2

a2 +a a

=

6 5

∈ Z. It is not transitive either, since

= a + 1 ∈ Z. On the

165 Deﬁnition Let ∼ be an equivalence relation on a set S . Then the equivalence class of a is deﬁned and denoted by

[a] = {x ∈ S : x ∼ a}.

166 Lemma Let ∼ be an equivalence relation on a set S . Then two equivalence classes are either identical or disjoint.

Proof: We prove that if (a, b) ∈ S 2 , and [a] ∩ [b] = ∅ then [a] = [b]. Suppose that x ∈ [a] ∩ [b]. Now x ∈ [a] =⇒ x ∼ a =⇒ a ∼ x, by symmetry. Similarly, x ∈ [b] =⇒ x ∼ b. By transitivity (a ∼ x) and (x ∼ b) =⇒ a ∼ b. Now, if y ∈ [b] then b ∼ y. Again by transitivity, a ∼ y. This means that y ∈ [a]. We have shewn that y ∈ [b] =⇒ y ∈ [a] and so [b] ⊆ [a]. In a similar fashion, we may prove that [a] ⊆ [b]. This establishes the result. u

39

Suppose that a child is playing with 10 bricks. called the target set of the function. an input parameter . we have [a] = Sα . 4. 5. 2. Suppose that instead of grouping the bricks by colour we decided to group the bricks by the remainder given by the number of the brick upon division by 4. thus a ≈ b if a and b leave the same remainder upon division by 4. We usually denote a typical input by the letter x. We deﬁne the relation ≈ on S by letting a ≈ b if and only if they belong to the same Sα . an assignment rule or formula. Conversely. let us consider the following example. 10} belong to the “2” class. assigning to every input a unique output. rule image target set domain Figure 4. This proves the ﬁrst half of the theorem. Sα ∩ Sβ = ∅ if α = β . we can deﬁne an equivalence relation on S whose equivalence classes are precisely these subsets.2 Functions 168 Deﬁnition By a function f : Dom ( f ) → Target ( f ) we mean the collection of the following ingredients: a name for the function. Clearly ≈ is also an equivalence relation. Since the Sα are mutually disjoint. Notice on the same set we constructed two different partitions. Suppose we induce the relation a ∼ b whenever brick number a has the same colour as brick number b. be a partition of S . The domain of f is denoted by Dom ( f ). bricks 4 through 7 are white and bricks 8 through 10 are blue. 3} belong to the “red” class. given a partition of S into disjoint. In this case bricks with numbers in {4. bricks with numbers in {4. also called independent variable or dummy variable. and bricks with numbers in {8.1: The main ingredients of a function. it is clear that ≈ is an equivalence relation on S and that for a ∈ Sα . Proof: By Lemma 166. 7} belong to the “3” class. bricks with numbers in {2. The output of x under f is also referred to as the image of x under f . 9} belong to the “1” class. u 4. 7} belong to the “white” class. The target set of f is denoted by Target ( f ). 9. Bricks 1 through 3 are red. a set of possible outputs of the function. non-empty subsets. S = α Sα . which come in 3 different colours and are numbered 1 through 10. a∈S and [a] ∩ [b] = ∅ if a Conversely. 10} belong to the “blue” class. 40 . The ∼ is clearly an equivalence relation and the bricks are partitioned according to colour. and is denoted by f (x). a set of inputs called the domain of the function. In this partition we have 3 classes (colours): bricks with numbers in {1. if ∼ is an equivalence relation on S then S = [a].40 Chapter 4 As a way of motivating the following result. This assignment rule for f is usually denoted by x → f (x). and that classes need not have the same number of elements. 6. and bricks with numbers in {3. Usually we use the letter f . let b. 8} belong to the “0” class. bricks with numbers in {1. 5. 167 Theorem Let S = ∅ be a set. Any equivalence relation on S induces a partition of S .

Functions

The notation1 f: Dom ( f ) x → → Target ( f ) f (x)

41

read “the function f , with domain Dom ( f ), target set Target ( f ), and assignment rule f mapping x to f (x)” conveys all the above ingredients. See ﬁgure 4.1.

169 Deﬁnition The image Im ( f ) of a function f is its set of actual outputs. In other words,

Im ( f ) = { f (a) : a ∈ Dom ( f )}. Observe that we always have Im ( f ) ⊆ Target ( f ). It must be emphasised that the uniqueness of the image of an element of the domain is crucial. For example, the diagram in ﬁgure 4.2 does not represent a function. The element 1 in the domain is assigned to more than one element of the target set. Also important in the deﬁnition of a function is the fact that all the elements of the domain must be operated on. For example, the diagram in 4.3 does not represent a function. The element 3 in the domain is not assigned to any element of the target set.

2 1 3

4 2 8 16

0 1 3

4 8

Figure 4.2: Not a function.

Figure 4.3: Not a function.

170 Example Consider the sets A = {1, 2, 3}, B = {1, 4, 9}, and the rule f given by f (x) = x2 , which means that f takes an input and squares it. Figures 4.4 through 4.5 give three ways of representing the function f : A → B.

{1, 2, 3} → {1, 4, 9} f: x → x2

f:

1 2 1 4

3 9

1 2 3

1 4 9

Figure 4.4: Example 170.

Figure 4.5: Example 170. Figure 4.6: Example 170.

171 Example Find all functions with domain {a, b} and target set {c, d}.

Solution: There are 22 = 4 such functions, namely: f2 given by f2 (a) = f2 (b) = d. Observe that Im ( f2 ) = {d}. f1 given by f1 (a) = f1 (b) = c. Observe that Im ( f1 ) = {c}.

** f3 given by f3 (a) = c, f3 (b) = d. Observe that Im ( f3 ) = {c, d}.
**

the difference in the arrows. The straight arrow −→ is used to mean that a certain set is associated with another set, whereas the arrow → (read “maps to”) is used to denote that an input becomes a certain output.

1 Notice

41

42

f4 given by f4 (a) = d, f4 (b) = c. Observe that Im ( f4 ) = {c, d}.

Chapter 4

172 Deﬁnition A function is injective or one-to-one whenever two different values of its domain generate two different values in its image.

A function is surjective or onto if every element of its target set is hit, that is, the target set is the same as the image of the function. A function is bijective if it is both injective and surjective.

1 2 3

α

2 8 4

1 2 3

β

4 2

1 2 3

γ

4 2

1 2

δ

4 2 8

Figure 4.7: An injection.

Figure 4.8: Not an injection

Figure 4.9: A surjection

Figure 4.10: Not a surjection

173 Example The function α in the diagram 4.7 is an injective function. The function represented by the diagram 4.8, however is not injective, since β (3) = β (1) = 4, but 3 = 1. The function γ represented by diagram 4.9 is surjective. The function δ represented by diagram 4.10 is not surjective since 8 is part of the target set but not of the image of the function. 174 Theorem Let f : A → B be a function, and let A and B be ﬁnite. If f is injective, then card (A) ≤ card (B). If f is surjective then

card (B) ≤ card (A). If f is bijective, then card (A) = card (B).

Proof: Put n = card (A), A = {x1 , x2 , . . . , xn } and m = card (B), B = {y1 , y2 , . . . , ym }. If f were injective then f (x1 ), f (x2 ), . . . , f (xn ) are all distinct, and among the yk . Hence n ≤ m. If f were surjective then each yk is hit, and for each, there is an xi with f (xi ) = yk . Thus there are at least m different images, and so n ≥ m. u

175 Deﬁnition A permutation is a function from a ﬁnite set to itself which reorders the elements of the set.

**By necessity then, permutations are bijective.
**

176 Example The following are permutations of {a, b, c}:

f1 : The following are not permutations of {a, b, c}: f3 :

a a

b b

c c

f2 :

a b

b c

c . a

a a

b a

c c

f4 :

a b

b b

c . a

177 Theorem Let A, B be ﬁnite sets with card (A) = n and card (B) = m. Then

• the number of functions from A to B is mn . • if n ≤ m, the number of injective functions from A to B is m(m − 1)(m − 2) · · · (m − n + 1). If n > m there are no injective functions from A to B. Proof: Each of the n elements of A must be assigned an element of B, and hence there are m · m · · · m = mn possibilities, and ßÞ thus mn functions.If a function from A to B is injective then we must have n ≤ m in view of Theorem 174. If to different inputs

n factors

42

Functions

we must assign different outputs then to the ﬁrst element of A we may assign any of the m elements of B, to the second any of the m − 1 remaining ones, to the third any of the m − 2 remaining ones, etc., and so we have m(m − 1) · · · (m − n + 1) injective functions. u

43

178 Example Let A = {a, b, c} and B = {1, 2, 3, 4}. Then according to Theorem 177, there are 43 = 64 functions from A to B and of these, 4 · 3 · 2 = 24 are injective. Similarly, there are 34 = 81 functions from B to A, and none are injective. 179 Example Find the number of surjections from A = {a, b, c, d} to B = {1, 2, 3}.

Solution: The trick here is that we know how to count the number of functions from one ﬁnite set to the other (Theorem 177). What we do is over count the number of functions, and then sieve out those which are not surjective by means of Inclusion-Exclusion. By Theorem 177, ¡ ¡ there are 34 = 81 functions from A to B. There are 3 24 = 48 functions from A to B that miss one element from B. There are 3 14 = 3 1 2 ¡ functions from A to B that miss two elements from B. There are 3 04 = 4 functions from A to B that miss three elements from B. By 0 Inclusion-Exclusion there are 81 − 48 + 3 = 36 surjective functions from A to B. In analogy to example 179, we may prove the following theorem, which complements Theorem 177 by ﬁnding the number of surjections from one set to another set.

180 Theorem Let A and B be two ﬁnite sets with card (A) = n and card (B) = m. If n < m then there are no surjections from A to B. If n ≥ m then the number of surjective functions from A to B is

mn −

m m m m (m − 1)n + (m − 2)n − (m − 3)n + · · · + (−1)m−1 (1)n . 1 2 3 m−1

43

v with au = b. There exist integers u. if a. That is. then u = ±1. Since b = 0 there exists an integer u = 0 with au = b. Since u. If c divides a and b then c divides any linear combination of a and b. u 184 Theorem (Division Algorithm) Let n > 0 be an integer. and so a|b =⇒ ka|kb. Then (ak)u = kb. n are integers with c|a. c be integers. c|b.t with sc = a.Chapter 5 Number Theory 5. 182 Example Since 20 = 4 · 5 we have 4|20. 183 Theorem Let a. There are integers u. Also −4|20 since 20 = (−4)(−5). we say that a divides b if there is an integer c such that ac = b. Proof: We prove the assertions in the given order. 44 . If a|b then a|kb for any k ∈ Z. If a|b and b|a. a|b ⇐⇒ ka|kb. Then a(uk) = bk and so a|bk. called the well-ordering principle: any non-empty set of non-negative integers has a smallest element. we use the following property of the integers. If a|b and b|c then a|c. giving c|(am + bn). and so uu = 1. bv = c.1 Division Algorithm 181 Deﬁnition If a = 0. Hence a = ±b. b are integers. Hence auu = bu = a. u = 1. neither a = 0 nor b = 0 if a|b and b|a. If a does not divide b we write a |b. u with au = b and bu = a. then a = ±b. b. For any k ∈ Z \ {0}. b. Proof: In the proof of this theorem. Thus Observe that by deﬁnition. There are integers s. If a|b and b = 0 then 1 ≤ |a| ≤ |b|. Hence auv = c. Since k = 0 we may cancel out the k’s and hence (ak)u = kb =⇒ au = b =⇒ a|b. and so a|c. There exist an integer u with au = b. proving the converse. m. We write this as a|b. Then for any integer a there exist unique integers q (called the quotient) and r (called the remainder) such that a = qn + r and 0 ≤ r < q. So |u| ≥ 1 and thus |a| · 1 ≤ |a| · |u| = |au| = |b|. There is u ∈ Z such that au = b. u are integers. c. am + nb = c(sm + tn). |a| ≥ 1 trivially.tc = b. then c|(am + nb).

. Now. . Then r2 − r1 = n(q1 − q2 ). Notice that d is a common divisor of 1253. we deduce that r = 164. This completes the proof. 3. . If p > 3. . . Since 1059 = 179q1 + r. 3. 187 Example Shew that the square of any prime greater than 3 leaves remainder 1 upon division by 12. −6.} = 4. . 895 = 5 · 179. 12. 0 ≤ r1 < n. ±3. −2. . 0 ≤ r2 < n. Solution: Observe that n2 + 23 = n2 − 1 + 24 = (n − 1)(n + 1) + 24. 9. Now. 15. . . 189 Example (AHSME 1976) Let r be the common remainder when 1059. From this it also follows that q1 = q2 . −9 −4 1 6 . which is divisible by 6 and hence not prime. . 45 . 5. . 10. 5Z + 1 = {. 11. produce inﬁnitely many values such that n2 + 23 is divisible by 24. ±1. . . . . . then the assertion is true for p = 3. 0. . 8. . −7. . 1. 17. . 19. those leaving remainder 1 upon division by 5. . 186 Example Shew that n2 + 23 is divisible by 24 for inﬁnitely many values of n. (6k ± 1)2 = 12(3k2 ± k) + 1. −14. . . −7 −2 3 8 . . . .} = 2. ±2. . −15. Thus we must have 0 ≤ r < n. then one of 8p − 1 and 8p + 1 is a prime and the other is composite. and 1059 = 5 · 179 + 164. . 14. . 5Z + 4 = {. assume that q1 n + r1 = a = q2 n + r2 . . −11.} = 0. . . 1417 and 2312 are divided by d > 1. Find d − r. Therefore the families of integers n = 24m ± 1. −6 −1 4 9 . . 895 = d(q3 − q2 ) and 358 = d(q2 − q1 ). −13. For assume that r ≥ n. −8. 6. Finally. q2 . then either p = 3k + 1 or p = 3k + 2. . . 8p − 1 = 23 and 8p + 1 = 25. Then r > r − n = a − qn − n = a − (q + 1)n ≥ 0. −9. .} = 1. −5. 2. . . . . since r − n ≥ 0. . q3 with 1059 = dq1 + r. then p is of one of the forms 6k ± 1. . and 358. . etc. . and so d = 179. 13. 8p − 1 = 24k − 15 is not a prime. . 2.Division Algorithm Consider the set S = {a − bn : b ∈ Z and a ≥ bn}. Then S is a collection of nonnegative integers and S = ∅ as ±a − 0 · n ∈ S and this is non-negative for one choice of sign.} = 3. . Solution: By the division algorithm there are integers q1 . 895. By the Well-Ordering Principle. . −4. n divides (r2 − r1 ). We let 5Z = {. and Z5 = {0. . d − r = 15. that is. . . Let us prove that r < n. By construction. proving the assertion. The arrangement above shews that any integer comes in one of 5 ﬂavours: those leaving remainder 0 upon division by 5. −10. r ≥ 0. Subtracting we get 1253 = d(q3 − q1 ). . 5Z + 2 = {. . 18. 190 Example Shew that if 3n + 1 is a square. To prove that r and q are unique. 7. . If p = 3k + 1. we see that 179 is the common divisor greater than 1 of all three quantities. . −12. Solution: If p > 3 is prime. −8 −3 2 7 . then n + 1 is the sum of three squares. . and 358 = 2 · 179. But |r2 − r1 | < n. If p = 3k + 2. . −1. . 5Z + 3 = {. As 1253 = 7 · 179. But then a − (q + 1)n ∈ S and a − (q + 1)n < r which contradicts the fact that r is the smallest member of S. u 185 Example If n = 5 the Division Algorithm says that we can arrange all the integers in ﬁve columns as follows: 45 . 1. 4. −3. 16. Solution: If p = 3. 188 Example Prove that if p is a prime. whence r2 = r1 . say r. . 1417 = dq2 + r and 2312 = dq3 + r. 8p − 1 = 24k − 7 and 8p + 1 = 24k − 6. m = 0. there must be some q ∈ Z such that r = a − qn since r ∈ S. −10 −5 0 5 . S has a least element. 4}.

denoted by d = gcd(a. rn ) = rn .1) The sequence of remainders will eventually reach a rn+1 which will be zero. n. r2 .1 r2 r3 r4 . r|r2 . The greatest common divisor d of a. . d divides a. . . y0 such that d = ax0 + by0 . By the Division Algorithm. then rn = gcd(a. A has a smallest element. Assume that t divides a and b. . From the ﬁrst equation. ±b is in A. = = bq1 + r2 . To do this we prove that d divides a and b and that if t divides a and b. (5. b. Then a = tm. b) is the largest positive integer that divides both a and b. then t must also divide then d.. 193 Theorem If rn is the last non-zero remainder found in the process of the Euclidean Algorithm. . we ﬁnd the sequence of equalities a b r2 . . But starting at the last equation 5. rn−2 − rn−1 qn−1 Let r = gcd(a. 0 < r2 < b. = a − bq1 b − r2 q2 r2 − r3 q3 . b). . rn = = = . This entails dq = a. as both a. we see that r|rn . i. i. Hence d = ax0 + bx0 = t(mx0 + ny0 ). . If r > 0. Upon iterating the process. By the Well Ordering Principle. there are integers x. The Euclidean Algorithm rests on the fact. Proof: From equations 5. Therefore n+1 = as we wanted to shew. rn |r2 .2 Greatest Common Divisor 191 Deﬁnition Let a. that gcd(a. 0 < rn < rn−1 . rn |b. . 0 < r3 < r2 .46 Solution: Clearly 3n + 1 is not a multiple of 3. b are not zero. r3 . Then r = a − dq = a(1 − qx0 ) − by0 . . y ∈ Z}. there are x0 . Clearly one of ±a. namely d. From the second equation. r|r3 . a contradiction. . that is. 46 . . and cannot contain more than b positive terms. . b can be written as a linear combination of a and b. Thus rn is a common divisor of a and b and so rn | gcd(a. . b) = ax + by. Thus r = 0. rn |a. then r ∈ A is smaller than the smaller element of A.e. . (3k ± 1)2 − 1 + 1 = 3k2 ± 2k + 1 = k2 + k2 + (k ± 1)2 . 3 Chapter 5 5. b be integers with one of them different from 0. and so 3n + 1 = (3k ± 1)2 . b). 0 < r4 < r3 . we see that rn |rn−1 . b be positive integers. u Let a. u 194 Example Write pseudocode describing the Euclidean Algorithm. . we can ﬁnd integers q. say d. This gives the desired result. r2 ) = gcd(r2 . r3 ) = · · · = gcd(rn−1 . Therefore. rn−1 qn−1 + rn rn qn . b). b). Proof: Let A = {ax + by|ax + by > 0. . .1 and working up. rn−2 rn−1 = = = . The theorem is thus proved. rn |rn−2 . is a monotonically decreasing sequence of integers. t divides d.e. After using the Division Algorithm repeatedly. 0 ≤ r < d such that a = dq + r. . x. r. y with gcd(a. to be proved below. We can similarly prove that d divides b. . We prove that d = gcd(a. We ﬁrst prove that d divides a. b = tn for integers m. 192 Theorem (Bachet-Bezout Theorem) The greatest common divisor of any two integers a. . b) = gcd(b. r2 q2 + r3 r3 q3 + r4 . since b.

2.1: E UCLIDEANA LGORITHM(x. y) if x < 0 then x ← −x if y < 0 then y ← −y while y > 0 ´ r ← x mod y do x ← y y←r . 47 Algorithm 5.Greatest Common Divisor Solution: Here is one iterative way of doing this.

An equation which requires integer solutions is called a diophantine equation. Hence. y that satisfy the linear diophantine equation 23x + 29y = 1. 5 = 5 · 1. with x = −5. thus gcd(23. y = 4. 47 . 5 = 23 − 3 · 6. Solution: We have 29 = 1 · 23 + 6. 197 Example Find integer solutions to 23x + 29y = 7. 196 Example Find integers x. 6 = 1 · 5 + 1. Multiplying both sides of this equality by 7. 6 = 29 · 1 − 23. 195 Example Find gcd(23. 23 = 3 · 6 + 5. Solution: We work upwards. 198 Example Find inﬁnitely many integer solutions to 23x + 29y = 1. 29) by means of the Euclidean Algorithm. 1 = = = = = 6−1·5 6 − 1 · (23 − 3 · 6) 4 · 6 − 1 · 23 4(29 · 1 − 23) − 1 · 23 4 · 29 − 5 · 23. 23(−35) + 29(28) = 7. By the Bachet-Bezout Theorem 192. we see that the linear diophantine equation ax + by = c has a solution in integers if and only if gcd(a. starting from the penultimate equality in the preceding problem: 1 = 6 − 1 · 5. 29) = 1. The Euclidean Algorithm is an efﬁcient means to ﬁnd a solution to this equation. which solves the problem. The last non-zero remainder is 1. 23(−5) + 29(4) = 1. This solves the equation. b)|c. Solution: From the preceding example.

Continuing in this way we deduce that 5213 = 211257 .3 Non-decimal Scales The fact that most people have ten ﬁngers has ﬁxed our scale of notation to the decimal. we can. and to a base-r number by using the subindex r. 16 13 a1 a2 a3 a4 = + 2 + 3 + 4 +··· 16 6 6 6 6 Multiplying by 6. We thus want to ﬁnd 0 ≤ a0 . rk ≤ n < rk+1 . ak = 0. however. y such that 3456x + 246y = 73? Chapter 5 Solution: No. 0 ≤ at ≤ r − 1. . 246) = 2 and 2 |73. We use the convention that we shall refer to a decimal number without referring to its base. 5 5 5 5 Thus 5627 = 289 = 21245 . 199 Example Can you ﬁnd integers x. . express any number x in base r. and so a3 = 1. Hence 13 4 7 a2 a3 a4 − = = 2 + 3 + 4 +··· 16 6 48 6 6 6 Solution: Write 48 . y0 = 4 is a solution. so the problem reduces to convert 289 to base-ﬁve. (3456. and r > 1 is an integer. 200 Example Express the decimal number 5213 in base-seven. . we obtain 2+ proper fraction = a4 + proper fraction. we obtain 4+ proper fraction = a1 + proper fraction. We can ﬁnd a family of solutions by letting x = −5 + 29t. Dividing by 74 . then n has the base-r representation n = a0 + a1 r + a2 r2 + · · · + ak rk . a4 = 0 such that 5213 = a4 74 + a3 73 + a2 72 + a1 7 + a0 . 202 Example Express the fraction 289 57 11 2 4 2 1 2 13 in base-six. Given any positive integer r > 1.48 Solution: By example 196. so a1 = 4. Reading from the last remainder up. Dividing by 73 this last equality we obtain 1+ proper fraction = a3 + proper fraction. a4 ≤ 6. The method of successive divisions used in the preceding problem can be conveniently displayed as 7 7 7 7 7 5212 744 106 15 2 5 2 1 1 2 The central column contains the successive quotients and the rightmost column contains the corresponding remainders. 201 Example Write 5627 in base-ﬁve. If n is a positive integer. This means that a4 = 2. Solution: Observe that 5213 < 75 . Thus 5213 = 2 · 74 + a3 73 + a2 72 + a1 7 + a0 or 411 = 5213 = a3 73 + a2 72 + a1 7 + a0 . we recover 5213 = 211257 . Solution: 5627 = 5 · 72 + 6 · 7 + 2 = in decimal scale. y = 4 − 23t. t ∈ Z. 5. the pair x0 = −5. . Doing successive divisions.

and so all the numbers in this sequence are congruent to a modulo n. . . 3. 1003 . . . Proof: Assume a = b. 12. By the Euclidean Algorithm there are integers q1 = q2 such that a = q1 n + r and b = q2 n + r. . .41r = 4 + 4 4 1 + = 2+ r r2 r 2 204 Example (AIME 1986) The increasing sequence 1. . 206 Example −8 ≡ 6 mod 7. 16 6 62 63 64 We may simplify this procedure of successive multiplications by recurring to the following display: 6 6 6 6 13 16 7 8 1 4 1 2 49 4 5 1 3 The third column contains the integral part of the products of the ﬁrst column and the second column. consists of all those positive integers which are powers of 3 or sums of distinct powers or 3. Thus the terms of the sequence in ascending order are 13 ..4 Congruences 205 Deﬁnition Let n > 0 be an integer. 49 . as a and b leave the same remainder when divided by n. . 8 4 203 Example Prove that 4. In the binary scale these numbers are. 4. 113 . . . Thus a − b = q1 n − q2 n = (q1 − q2 )n. r − n. and so a2 = 5.Congruences Multiply by 62 we obtain 5+ proper fraction = a2 + proper fraction. Solution: If the terms of the sequence are written in base-three. Continuing in this fashion 13 4 5 1 3 = + + + = 0. Therefore to obtain the 100th term of the sequence we write 100 in binary and then translate this into ternary: 100 = 11001002 and 11001003 = 36 + 35 + 32 = 981.45136 . Each term of the second column from 13 7 the second on is the fractional part of the product obtained in the preceding row. otherwise the result is clear. . 4. of course. 9. . Solution: 4. Find the hundredth term of the sequence. etc. This implies that n|(a − b). Then a ≡ b mod n ⇐⇒ n|(a − b). Thus 6 · 16 − 4 = 7 . r − 3n. . 1113 . the ascending natural numbers 1.41r is a perfect square in any scale of notation. By the division algorithm any integer a can be written as a = qn + r with 0 ≤ r < n. 13. . 103 . 6 · 8 − 5 = 1 . 5. they comprise the positive integers which do not contain the digit 2. r. 1103 . r + 3n. 207 Theorem Let n > 0 be an integer. By letting q vary over the integers we obtain the arithmetic progression . We say that “a is congruent to b modulo n” written a ≡ b mod n if a and b leave the same remainder upon division by n. 10. 2. 3.. −8 ≡ 13 mod 7. r + n. . r + 2n. . r − 2n. . 1013 .

72 ≡ 1 mod 4 and so 77 ≡ (72 )3 · 7 ≡ 3 mod 4. we can ﬁnd k1 . Also.50 Chapter 5 Conversely if n|(a − b) then there is an integer t such that nt = a − b. 210 Example Prove that 7 divides 32n+1 + 2n+2 for all natural numbers n. including any leap year. Hence 32n+1 + 2n+2 ≡ 7 · 2n ≡ 0 for all natural numbers n. Assume that a = m1 n + r1 and b = m2 n + r2 with 0 ≤ r1 . 72 ≡ −1 mod 10. mod 7. which is patently false. ac ≡ bd mod m 5. u Congruences mod 9 can sometimes be used to check multiplications. Solution: 2222 ≡ 3 mod 7. u We now provesome simple properties of congruences. If f is a polynomial with integral coefﬁcients then f (a) ≡ f (b) mod m. k2 ∈ Z with a = b + k1 m and c = d + k2 m. Thus a ± c = b ± d + m(k1 ± k2 ) and ac = bd + m(k2 b + k1 d). Now 22225555 + 55552222 ≡ 35555 + 42222 ≡ (35 )1111 + (42 )1111 ≡ 51111 − 51111 ≡ 0 mod 7. 212 Example Find the units digit of 77 . and so 73 ≡ 72 · 7 ≡ −7 ≡ 3 mod 10 and 74 ≡ (72 )2 ≡ 1 mod 10. Since |r1 − r2 | < n we must have r1 − r2 = 0 and so a and b leave the same remainder upon division by n. Proof: As a ≡ b mod m and c ≡ d mod m. 5555 ≡ 4 mod 7 and 35 ≡ 5 mod 7. 211 Example Prove that 7|(22225555 + 55552222 ). d. But this says that 0 · 8 ≡ 8 mod 9. For example 875961 · 2753 = 2410520633. These equalities give (1). ak ≡ bk mod m 3. b. Now. 77 ≡ 74t+3 ≡ (74 )t · 73 ≡ 1t · 3 ≡ 3 Thus the last digit is 3. Property (4) follows by successive application of (3). 213 Example Prove that every year. and (5) follows from (4). 7 Solution: We must ﬁnd 77 mod 10. (2) and (3). m ∈ Z. Solution: Observe that 32n+1 ≡ 3 · 9n ≡ 3 · 2n mod 7 and 2n+2 ≡ 4 · 2n mod 7. 208 Theorem Let a. Upon assembling all this. Then nt = a − b = (m1 − m2 )n + r1 − r2 =⇒ n(t − m1 + m2 ) = r1 − r2 =⇒ n|(r1 − r2 ). Then 1. a + c ≡ b + d mod m 2. Thus 61987 ≡ 6 · 61986 ≡ 6(62 )993 ≡ 6(−1)993 ≡ −6 ≡ 31 mod 37. 7 7 mod 10. Solution: 62 ≡ −1 mod 37. a − c ≡ b − d mod m 4. c. r2 < n. For if this were true then (8 + 7 + 5 + 9 + 6 + 1)(2 + 7 + 5 + 3) ≡ 2 + 4 + 1 + 0 + 5 + 2 + 0 + 6 + 3 + 3 mod 9. k ∈ with a ≡ b mod m and c ≡ d mod m. 209 Example Find the remainder when 61987 is divided by 37. 50 . which means that there is an integer t such that 77 = 3 + 4t. has at least one Friday 13th.

5 Divisibility Criteria 216 Theorem An integer n is divisible by 5 if and only if its last digit is a 0 or a 5. . This produces the inﬁnitely many values sought. for if n < 0 we simply apply the result to −n > 0. 24 ≡ 2. Solution: Observe that 21 ≡ 2. 1. . thus each year. 5.Divisibility Criteria 51 Solution: It is enough to prove that each year has a Sunday the 1st. we have n = as 10s + as−1 10s−1 + · · · + a1 10 + a0 ≡ a0 mod 5. depending on whether the year is a leap year or not. Proof: If n = 0 there is nothing to prove. 26 ≡ 1 mod 7 and so 23k ≡ 1 mod 3 for all positive integers k. 215 Example Prove that 2k − 5. k = 0. Hence 23k + 27 ≡ 1 + 27 ≡ 0 mod 7 for all positive integers k. An integer n is divisible by 2k if and only if the number formed by the last k digits of n is divisible by 2k . 23 ≡ 1 mod 7. Thus 2k − 5 can leave only remainders 3. So assume that n ∈ Z. or 6 upon division by 7. Thus divisibility of n by 5 depends on whether a0 is divisible by 5. If we prove the result for n > 0 then we can deduce the result for n < 0 by applying it to −n = (−1)n > 0. that March 1st is the 50th or 51st day of the year. never leaves remainder 1 when divided by 7. Proof: We derive the result for n > 0. whether leap or not. . n > 0 and let its decimal expansion be n = as 10s + as−1 10s−1 + · · · + a1 10 + a0 . 25 ≡ 4. and this cycle of three repeats. Now. has at least one Sunday the 1st. 22 ≡ 4. 51 . 2. 23 ≡ 1. each remainder class modulo 7 is represented in the third column. 4.) Now. Solution: 21 ≡ 2. the ﬁrst day of a month in each year falls in one of the following days: Month January February March April May June July August September October November December Day of the year 1 32 60 or 61 91 or 92 121 or122 152 or 153 182 or183 213 or 214 244 or 245 274 or 275 305 or 306 335 or 336 1 4 4 or 5 0 or 1 2 or 3 5 or 6 0 or 1 3 or 4 6 or 0 1 or 2 4 or 5 6 or 0 mod 7 (The above table means that. 22 ≡ 4. 214 Example Find inﬁnitely many integers n such that 2n + 27 is divisible by 7. Since 10k ≡ 0 mod 5 for integral k ≥ 1. which happens only when a0 = 0 or a0 = 5. etc. u 217 Theorem Let k be a positive integer.

3216 is divisible by 16.52 where 0 ≤ ai ≤ 9. u 218 Example The number 987654888 is divisible by 23 = 8 because the number formed by its last three digits. Since 0 ≤ a ≤ 9. 220 Example By what digits may one replace A so that the integer 231A2 be divisible by 4? Solution: The number 231A2 is divisible by 4 if and only if A2 is divisible by 4. and A = 9 (A2 = 92). Proof: If n = 0 there is nothing to prove. A = 3 (A2 = 32). If 235ab is divisible by 8 then. 23520. thus d = 8. 224 Example Is there a digit d so that 125d be divisible by 45? 52 . where 0 ≤ ai ≤ 9. The only number in the range 10 to 19 divisible by 9 is 18. One can easily verify that 3285 is divisible by 9. Thus the ﬁve numbers 23112. 0 ≤ d ≤ 9 =⇒ 10 ≤ d + 10 ≤ 19. A = 5 (A2 = 52). 23540. 2315223172. as = 0. 23580. This happens when A = 1 (A2 = 12). So assume that n ∈ Z. Observe that 10 ≡ 1 mod 9 and so 10t ≡ 1t ≡ 1 mod 9. Now n = ≡ from where the result follows. Thus we need a digit a so that 5a0 be divisible by 8. it is even and since we also require it to be divisible by 5 we must have b = 0. each of 10t = 2t 5t ≡ 0 mod 2t for t ≥ k. u as 10s + as−1 10s−1 + · · · + a1 10 + a0 as + · · · + a1 + a0 mod 9. 888 is divisible by 8. 223 Example What values should the digit d take so that the number 32d5 be divisible by 9? Solution: The number 32d5 is divisible by 9 if and only 3 + 2 + d + 5 = d + 10 is divisible by 9. 222 Theorem (Casting-out 9’s) An integer n is divisible by 9 if and only if the sum of its digits is divisible by 9. 221 Example Determine digits a. are all divisible by 4. If we prove the result for n > 0 then we can deduce the result for n < 0 by applying it to −n = (−1)n > 0. 23560. b so that 235ab be divisible by 40. 219 Example The number 191919191919193216 is divisible by 24 = 16 because the number formed by its last four digits. A = 7 (A2 = 72). a fortiori. Solution: 235ab will be divisible by 40 if and only if it is divisible by 8 and by 5. Now. Chapter 5 so n is divisible by 2k if and only if the number formed by the last k digits of n is divisible by 2k . a quick trial an error gives that the desired integers are 23500. Since 10 ≡ 1 mod 3 we can also deduce that integer n is divisible by 3 if and only if the sum of it digits is divisible by 3. n > 0 and let its decimal expansion be n = as 10s + as−1 10s−1 + · · · + a1 10 + a0 . 23192. Now. 23132. as = 0. Hence n = ≡ as 10s + as−1 10s−1 + · · · + a1 10 + a0 ak−1 10k−1 + ak−2 10k−2 + · · · + a1 10 + a0 mod 2k .

4. Deduce that if x = y are integers then (x − y)|xn − yn . 230 Problem Find the least positive integer solution of the equation 436x − 393y = 5. 3. whereas 8924310064539 has alternating digital sum 8 − 9 + 2 − 4 + 3 − 1 + 0 − 0 + 6 − 4 + 4 − 3 + 9 = 11. If d = 0. 232 Problem Prove that any integer n > 11 is the sum of two positive composite numbers. 233 Problem Let n > 1 be an integer. that if a = 1 then 1 + a + a2 + · · · an−1 = 2. Shew that 2903n − 803n − 464n + 261n is divisible by 1897 for all natural numbers n. it must be divisible by 9 and by 5.Homework 53 Solution: If 125d were divisible by 45. if d = 5. By making the substitution a = x y 1 − an . Observe that 10 ≡ −1 mod 11and so 10t ≡ (−1) mod 11. 1. the digital sum is 1 + 2 + 5 + 0 = 8. which is not divisible by 9. the digital sum is 1 + 2 + 5 + 5 = 13. using induction or otherwise. 53 . 227 Theorem An integer n is divisible by 11 if and only if its alternating digital sum is divisible by 11. Similarly. If it were divisible by 5. 1−a prove that xn − yn = (x − y)(xn−1 + xn−2 y + · · · + xyn−2 + yn−1 ). 231 Problem Two rods of equal length are divided into 250 and 243 equal parts. So 125d is never divisible by 45. Homework 229 Problem Prove that there are inﬁnitely many integers n such that 4n2 + 1 is simultaneously divisible by 13 and 5. Prove. respectively. as = 0. and so 8924310064539 is divisible by 11. Let n = as 10s + as−1 10s−1 + · · · + a1 10 + a0 . Proof: We may assume that n > 0. where 0 ≤ ai ≤ 9. the alternating digital sum of n is as − as−1 + as−2 − as−3 + · · · + (−1)s−1 a0 226 Example The alternating digital sum of 135456 is 1 − 3 + 5 − 4 + 5 − 6 = −2. then d = 0 or d = 5. Hence n = ≡ as 10s + as−1 10s−1 + · · · + a1 10 + a0 as (−1)s + as−1 (−1)s−1 + as−2 (−1)s−2 + · · · + −a1 + a0 mod 11 and the result follows from this. u 228 Example 912282219 has alternating digital sum 9 − 1 + 2 − 2 + 8 − 2 + 2 − 1 + 9 = 24 and so 912282219 is not divisible by 11. 225 Deﬁnition If the positive integer n has decimal expansion n = as 10s + as−1 10s−1 + · · · + a1 10 + a0 . If their ends be coincident. which is neither divisible by 9. ﬁnd the divisions which are the nearest together.

and from (1 − a)S = S − aS = 1 − an we obtain the result. 230 Using the Euclidean Algorithm. we seek solutions of 243x − 250y = ±1. 235 Problem Write an algorithm that ﬁnds integer solutions x. 250) = 1. Hint: 340 ≡ 1 mod 100. 436 393 43 Hence 1 = = = = = 43 − 7 · 6 43 − 7 · (393 − 9 · 43) −7 · 393 + 64 · 43 −7 · 393 + 64 · (436 − 393) −71 · 393 + 64 · 436. Then aS = a + a2 + · · · + an−1 + an . Answers 229 We have 4n2 + 1 = 4n2 − 64 + 65 = 4(n − 4)(n + 4) + 65 so it is enough to take n = 65k ± 4. then n = 2k for some integer k. 234 Problem Use the preceding problem to ﬁnd the prime factor p > 250000 of the integer 1002004008016032. then (x + y)|xn + yn . How many 1 gallon and half gallon containers did he sell? 238 Problem Using congruences. b) = ax + by. = = = 1 · 393 + 43 9 · 43 + 6 7·6+1 and so 5 = 320 · 436 − 355 · 393. Assume that at least one of a or b is different from 0. that is. 7. y = 355 + 436t. 233 1. Thus S − aS = (1 + a + a2 + · · · + an−1 ) − (a + a2 + · · · + an−1 + an ) = 1 − an . 232 If n > 11 is even then n − 6 is even and at least 12 − 4 = 8 and thus it is composite. Hence n = (n − 6) + 6 is the sum of two even composite numbers. 54 . y to the equation gcd(a. Prove that if A + A = 1010 . Prove that if 2n + 1 is prime. An inﬁnite set of solutions can be achieved by putting x = 320 + 393t. and hence composite. 236 Problem Let A be a positive integer. Therefore n = (n − 9) + 9 of an even and an odd composite number.54 5. 237 Problem A grocer sells a 1-gallon container of milk for 79 cents (comment: those were the days!) and a half gallon container of milk for 41 cents. Prove that if 2n − 1 is prime. and n is odd. Put S = 1 + a + a2 + · · · + an−1 . At the end of the day he sold $63. By using the Euclidean Algorithm we ﬁnd 243 · 107 − 250 · 104 = 1 and also 243 · (250 − 107) − 250 · (243 − 104) = −1 and so the values of x are 107 and 143 and those of y are 104 and 139.58 worth of milk. then n must be prime. and so the divisions will be nearest together when they differ by the least amount. Deduce that if x = y are integers. and A be a number written with the aid of the same digits with are arranged in some other order. 231 Observe that gcd(243. If n > 11 is odd then n − 9 is even at least 13 − 9 = 4. then A is divisible by 10. ﬁnd the last two digits of 3100 . Chapter 5 6.

which gives the result. a−b 235 Here a possible approach. This is immediate from the above result. From x 1+ + y we obtain 1− x y x 1+ + y x y 2 55 x y 2 +···+ x y n−1 = 1− x y x 1− y n +··· + x y n−1 = 1− x y n . If n is odd then −(−y)n = yn . 6. (a + b)(a2 + ab + b2 )(a2 − ab + b2 ) 1002 · 1002004 · 998004 4 · 4 · 1002 · 250501 · k. 2903n −803n is divisible by 2903−803 = 2100 = 7·300 =. Since 7 and 271 have no prime factors in common. 3. k k k k 234 If a = 103 . 2a − 1 > 1. Primes of this form are called Fermat primes. Therefore p = 250501. 5. and multiplying by yn both sides gives the result. we can conclude that the expression is divisible by 7 · 271 = 1897. k k k k k k k m + 1 = (22 + 1)((22 )m−1 − (22 )m−2 + · · · − (22 )1 + 1).Answers 2. I have put semicolons instead of writing the algorithm strictly vertically in order to save space. Thus the expression is also divisible by 271. Since b > 1. 7. (2a )b−1 + (2a )b−2 + · · · (2a )1 + 1) ≥ 2a + 1 > 1. 4. b = 2 then 1002004008016032 = a5 + a4 b + a3 b2 + a2 b3 + ab4 + b5 = This last expression factorises as a6 − b6 a−b = = = where k < 250000. Since a > 1. we have produced two factors each greater than 1 for the prime 2n + 1. that is x + y divides xn − (−y)n . 55 . each greater than 1. We have decomposed a prime number (the left hand side) into the product of two factors. and 261n −464n is divisible by 261−464 = −203 = 7 · (−29). 22 + 1 > 1. By changing y into −y we deduce that x − (−y) divides xn − (−y)n . We have 2n − 1 = 2ab − 1 = (2a − 1)((2a )b−1 + (2a )b−2 + · · · + (2a )1 + 1). By the preceding part. a contradiction. a6 − b6 . We have 2n + 1 = 22 Clearly. Thus n must be a prime. which is nonsense. For every n we have that x − y divides xn − yn . and so. 2903n − 464n is divisible by 2903 − 464 = 9 · 271 and 261n − 803n is divisible by −542 = (−2)271. Thus the expression 2903n − 803n − 464n + 261n is divisible by 7. Also. Primes of this form are called Mersenne primes. Also if m ≥ 3 (22 )m−1 − (22 )m−2 + · · · − (22 )1 + 1 ≥ (22 )2 − (22 )1 + 1 > 1.

m ← m − n. q ← q − s.56 Algorithm 5. s ← 1. q ← 0. k ← m. while ¬((m = 0) ∨ (n = 0)) if m ≥ n then else if m = 0 then else k ← n. n ← n − m.1: L INEAR D IOPHANTINE(a. y ← q. x ← r. r ← r − p. Chapter 5 . p ← 1. b) m ← a. r ← 0. p ← p − r. y ← s.5. n ← b. x ← p. s ← s − q.

Now (all congruences mod 100) 34 ≡ 81 =⇒ 38 ≡ 812 ≡ 61 =⇒ 316 ≡ 612 ≡ 21. 38 = 3 · 12 + 2. 0 ≤ j ≤ 9 for which a1 + a1 = a2 + a2 = · · · = a j + a j = 0.58 =⇒ 79x + 41y = 6358. 56 . Now. . simultaneously −89012 + 41t ≥ 0 =⇒ t ≥ 2172 ∧ 171666 − 79t ≥ 0 =⇒ t ≤ 2172. a j+1 + a j+1 = 10. This implies that j must be odd. But this implies that a1 + a1 = 0. and indeed . 3 = 1 · 2 + 1. and j = 9 implies that there are no sums of the form al + al . On adding all these sums.79(40) + .58. which gives the result. we gather a1 + a1 + a2 + a2 + · · · + a10 + a10 = 10 + 9(9 − j). y) = (−14. 237 We want non-negative integer solutions to the equation . . Using the Euclidean Algorithm we ﬁnd. 236 Clearly A and A must have ten digits. k ≥ 2. a1 be the consecutive digits of A and A = a10 a9 . we see that the sinistral side of the above equality is the even number 2(a1 + a2 + · · · + a10 ). . a1 . we only need to concern ourselves with the last quantity. 27).79x + . as 20 = 16 + 4. 320 ≡ 316 34 ≡ (21)(81) ≡ 1 mod 100.41(78) = 63. We need non-negative solutions so we need. Let A = a10 a9 . 41 = 1 · 38 + 3. Thus 79(−89012) + 41(171666) = 6358 and the parametrisation 79(−89012 + 41t) + 41(171666 − 79t) = 1 provides inﬁnitely many solutions. a j+2 + a j+2 = a j+3 + a j+3 = · · · = a10 + a10 = 9. successively 79 = 1 · 41 + 38. Hence 1 = = = = = = = 3−2 3 − (38 − 3 · 12) −38 + 3 · 13 −38 + (41 − 38) · 13 38 · (−14) + 41 · 13 (79 − 41)(−14) + 41 · 13 79(−14) + 41(27) A solution to 79x + 41y = 1 is thus (x.41y = 63. Thus taking t = 2172 we obtain x = −89012 + 41(2172) = 40 and y = 171666 − 79(2172) = 78. We deduce. Since the as are a permutation of the as . 1 ≤ l ≤ j. Notice that j = 0 implies that there are no sums of the form a j+k + a j+k . A + A = 1010 if and only if there is a j. . that and the last two digits are 01. 238 Since 3100 ≡ (340 )2 320 ≡ 320 mod 100.

8. (−1. y) are there such that 0 < |xy| ≤ 5? Solution: Put Ek = {(x. Then card (E1 ∪ E2 ∪ · · · ∪ Ek ) = card (E1 ) + card (E2 ) + · · · + card (Ek ) . −1). 5. . 5). 243 Example The positive divisors of 400 are written in increasing order 1. −4). −2). −5). (4. 4). 4). Then card (E1 × E2 × · · · × Ek ) = card (E1 ) · card (E2 ) · · · card (Ek ) . −1). . . (1.Chapter 6 Enumeration 6. . be ﬁnite sets. then its cardinality is the number of elements it has. (−1. . 1)} The desired number is therefore 4 + 8 + 8 + 12 + 8 = 40. 1)} {(−5. (−3. −3). E2 . (1. −2). 2). 242 Example How many ordered pairs of integers (x. −2). 4. 2. (3. (2. (2. −1). Thus there are 5 choices for a and 3 choices for b for a total of 5 · 3 = 15 positive divisors. (5. 200. (1. (1. (−1. (5. −2). 1). (2. . . Then the desired number is card (E1 ) + card (E2 ) + · · · + card (E5 ) . . We denote the cardinality of S by card (S). (−2. (1. (−5. (4. . 239 Deﬁnition (Cardinality of a Set) If S is a set. Ek .1 The Multiplication and Sum Rules We begin our study of combinatorial methods with the following two fundamental principles. (−2. (−1. (1. (2. E2 . −5). . 240 Rule (Sum Rule: Disjunctive Form) Let E1 . 1). any positive divisor of 400 has the form 2a 5b where 0 ≤ a ≤ 4 and 0 ≤ b ≤ 2. −1). (−1. (1. How many integers are there in this sequence. . 2). 2). −4). . (1. How many of the divisors of 400 are perfect squares? Solution: Since 400 = 24 · 52 . −1). Then E1 E2 E3 E4 E5 = = = = = {(−1. 400. y) ∈ Z2 : |xy| = k} for k = 1. Ek . . (−1. 2). 3). 5). 1)} {(−4. (−1. −1). (1. (−1. 3). 241 Rule (Product Rule) Let E1 . . (1. 57 . 5. . . (−2. −1). 1). be pairwise ﬁnite disjoint sets. 1). (−4. −1). 1). (−1. 1)} {(−3. (3. −3). −1). 1)} {(−2. −1).

By arguing as in example 243. . 500). so each digit is used 300 times. . (3. as in ﬁgure 6. we have a total of 64 + 64 − 1 = 127 paths.1: Problem 245. The the sum of the digits in the interval 000 to 999 is thus (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)(300) = 13500. Find the sum of all the digits. Solution: When writing the integers from 000 to 999 (with three digits). we obtain the following theorem.58 Chapter 6 To be a perfect square. (1. 998). Thus there are 3 · 2 = 6 divisors of 400 which are also perfect squares. Aliter: Pair up the integers from 0 to 999 as (0. 4} and β ∈ {0. 246 Example The integers from 1 to 1000 are written in succession. Since every required path must use the bottom right T . .2. Therefore. 2}. and since at each stage we can go either up or left. 996). the sum of the digits when writing the integers from 1 to 1000 is 13500 + 1 = 13501. Solution: Split the diagram. If d(n) denotes the number of positive divisors of n. Adding 1 for the sum of digits of 1000. Each of the 10 digits is used an equal number of times. 58 . Figure 6. Since the middle column is shared by both halves. we count paths starting from this T and reaching up to a C. the required total is 27 · 500 + 1 = 13501. 999). then d(n) = (a1 + 1)(a2 + 1) · · · (ak + 1). The other half of the ﬁgure will provide 64 more paths. and the ai are integers ≥ 1.2: Problem 245. each segment connecting a pair of adjacent letters in ﬁgure 6. (2. we have 26 = 64 paths. (499. 244 Theorem Let the positive integer n have the prime factorisation n = pa1 pa2 · · · pak . 1 2 k where the pi are different primes. Since there are six more rows that we can travel to. . 2. Each pair has sum of digits 27 and there are 500 such pairs. a positive divisor of 400 must be of the form 2α 5β with α ∈ {0.1 spell CONT EST ? C C C C C C C O O N O N T O N T E O N T E S O N T E S T C O C N T E S O N T T C O N E C O C N O C C C O C O N C O N T C O N T E C O N T E S C O N T E S T Figure 6. 3 × 1000 = 3000 digits are used. 997). 245 Example (AHSME 1977) How many paths consisting of a sequence of horizontal and/or vertical line segments.

and repetition is allowed. 2-digit integers. the third digit of 4027. b. 18. 11. In this case there are 4·3 + 4 = 10 possible selections: 2 aa ab bb ac bc cc ad bd cd dd 59 . 16. a total of 9 + 180 + 2700 = 2889 digits have been used. Depending on our interpretation. and repetition is allowed. c. that is.2 Combinatorial Methods Most counting problems we will be dealing with can be classiﬁed into one of four categories. In this case there are 4 · 4 = 16 possible selections: aa ba ca da ab bb cb db ac bc cc dc ad bd cd dd Permutations without repetitions. 248 Example Consider the set {a. d}. 8. Suppose we “select” two letters from these four. so the 3000-th digit is the third digit of the 28-th 4-digit integer. 20. 3-digit integers. 4. We explain such categories by means of an example. we may obtain the following answers. 6. 7. Which digit occupies the 3000-th position? Solution: Upon using 9·1 = 9 90 · 2 = 180 900 · 3 = 2700 1-digit integers. There remains to use 3000 − 2889 = 111 digits. 13. Permutations with repetitions. The order of listing the letters is important. 6. . 17. In this case there are 4 · 3 = 12 possible selections: ab ba ca da cb db dc ac bc ad bd cd Combinations with repetitions. 10. and repetition is not allowed. so the 3000-th digit must belong to a 4-digit integer. 5. The order of listing the letters is not important.Combinatorial Methods 247 Example The strictly positive integers are written in succession 59 1. . 15. 12. 3. 9. and 111 = 4 · 27 + 3. . 2. namely 2. 14. The order of listing the letters is important. 19.

n! is read n factorial. n! = 1 · 2 · 3 · · · n. In this case there 4·3 are = 6 possible selections: 2 ab ac bc ad bd cd We will now consider some examples of each situation. 1 · 2 · 3 · 4 · 5 = 120. and for integer n ≥ 1.1: FACTORIAL(n) comment: returns n! m←1 while n > 1 m ← n∗m n ← n−1 . Algorithm 6.2. and repetition is not allowed. 250 Example We have 1! 2! 3! 4! 5! = = = = = 1. 6.2. 251 Example Write a code fragment to compute n!. 1 · 2 = 2.1 Permutations without Repetitions 249 Deﬁnition We deﬁne the symbol ! (factorial). 1 · 2 · 3 = 6. Solution: The following is an iterative way of solving this problem. 1 · 2 · 3 · 4 = 24. The order of listing the letters is not important.60 Chapter 6 Combinations without repetitions. as follows: 0! = 1.

A permutation of these objects is simply a rearrangement of them. 60 . xn be n distinct objects. return (m) 252 Deﬁnition Let x1 . . x2 . . . .

. namely 61 MAT H AMT H TAMH HAT M MAHT AMHT TAHM HAMT MTAH AT MH T MAH HTAM MT HA AT HM T MHA HT MA MHTA AHT M T HMA HMTA MHAT AHMT T HAM HMAT 254 Theorem Let x1 . etc.2: P ERMUTATIONS(n) k ← n−1 while X[k] > X[k − 1] k ← k−1 t ← k+1 while ((t < n) and (X[t + 1] > X[k])) t ← t +1 comment: now X[k + 1] > . We use examples 13 and 23. the second object in n − 1 ways.Combinatorial Methods 253 Example There are 24 permutations of the letters in MAT H. Algorithm 6. . xn be n distinct objects. . . . the third in n − 2. This gives n(n − 1)(n − 2) · · · 2 · 1 = n!. . > X[n] Swap(X[k]. . u 255 Example Write a code fragment that prints all n! of the set {1. . X[n]) . . . > X[t] > X[k] > X[t + 1] > . > X[n] ReverseArray(X[k + 1]. x2 . . Proof: The ﬁrst position can be chosen in n ways. 2.2. Solution: The following programme prints them in lexicographical order. . n}. .. . . . Then there are n! permutations of them. X[t]) comment: now X[k + 1] > . .

Each book is different from one another. 7 Spanish books and 8 French books. 256 Example A bookshelf contains 5 German books. How many different arrangements can be done of these books? How many different arrangements can be done of these books if books of each language must be next to each other? Solution: How many different arrangements can be done of these books if all the French books must be next to each other? How many different arrangements can be done of these books if no two French books must be next to each other? 61 .

Also. To assure that all the French books are next each other. We permute the 3 languages in 3! ways. observe that there are 900 terms. Putting these 5 + 7 = 12 books creates 12 + 1 = 13 spaces (we count the space before the ﬁrst book.2 Permutations with Repetitions We now consider permutations with repeated objects. To assure that no two French books are next to each other. Thus the number of arrangements sought is 20! = 2432902008176640000. there are 900 − 729 = 171 such integers. Solution: Using example 257. this will assure that books of the same language are together. the Spanish books in 7! ways and the French books in 8! ways. 257 Example Determine how many 3-digit integers written in decimal notation do not have a 0 in their decimal expansion. which is 24856274386944000. etc. The required sum is 494550 − 404595 = 89955. + + + 101 998 1099 + + + ··· ··· ··· + + + 999 100 1099 900(1099) = 494550. and that you obtain the same sum adding backwards as forwards: S S 2S = = = = giving S = 100 999 1099 900(1099). “Glue” the books by language. the spaces between books and the space after the last book). Hence the required sum is 81(1 + 2 + · + 9)100 + 81(1 + 2 + · + 9)10 + 81(1 + 2 + · + 9)1 = 404595. 259 Example In how many ways may the letters of the word MASSACHUSET T S be permuted? Solution: We put subscripts on the repeats forming MA1 S1 S2 A2CHUS3 ET1 T2 S4 . then given for every ﬁxed choice of a variable. there are 9 · 9 = 81 choices of the other two variables. the French books can be permuted in 8! ways and the non-French books can be permuted in 12! ways. the non-French books can be permuted in 12! ways. the second into any of 12. Putting these 5 + 7 = 12 books creates 12 + 1 = 13 spaces (we count the space before the ﬁrst book. the spaces between books and the space after the last book). If 100x + 10y + z is such an integer. Thus the total number of permutations is (13)(12)(11)(10)(9)(8)(7)(6)12!. Align the German books and the Spanish books ﬁrst. What is the sum of all these integers. The ﬁrst French book can be put into any of 13 spaces. Now. ﬁnd the sum of all these 3-digit numbers. Solution: There are 9 · 9 · 9 = 729 3-digit integers not possessing a 0 in their decimal expansion. Thus the total number of permutations is (13)8!12! = 251073478656000. Hence the total number of ways is 3!5!7!8! = 146313216000. 62 . we put them into these spaces. Now. To obtain this sum.. we “glue” them together and put them in one of these spaces. 258 Example Determine how many 3-digit integers written in decimal notation possess at least one 0 in their decimal expansion. the eighth French book can be put into any 6 spaces. 2 6. The sum of all the three digit integers is 100 + 101 + · · · + 998 + 999.62 We are permuting 5 + 7 + 8 = 20 objects. Chapter 6 Align the German books and the Spanish books ﬁrst.2. We permute the German books in 5! ways.

For each of these 13! permutations. Then the number of ways in which these n1 + n2 + · · · + nk objects can be rearranged is (n1 + n2 + · · · + nk )! . MU then the R could be arranged as follows: M U R R . 3) Thus the number desired is 3 + 6 + 6 + 3 + 3 + 6 + 1 = 28. n2 of type 2. H. etc. c) (1. T. 2!2! 262 Example In how many ways may we write the number 9 as the sum of three positive integer summands? Here order counts. S. 1. 263 Example In how many ways can the letters of the word MURMUR be arranged without letting two letters which are alike come Number of permutations 3! =3 2! 3! = 6 3! = 6 3! =3 2! 3! =3 2! 3! = 6 3! =1 3! together? Solution: If we started with. 5) (1. b. A1 A2 can be permuted in 2! ways. S. 2!4!2! A reasoning analogous to the one of example 259. say . Solution: We ﬁrst look for answers with a + b + c = 9. S. M M U U R R R . C. 2. E. 3. Thus the over count 13! is corrected by the total actual count 13! = 64864800. H. T. R . 4) (2.Combinatorial Methods 63 There are now 13 distinguishable objects. 5) (2. 7) (1. we may prove 260 Theorem Let there be k types of objects: n1 of type 1. 1 + 7 + 1 is to be regarded different from 7 + 1 + 1. 4) (3. so. 6) (1. U. 63 . S there are four S’s and two T ’s and so the total number of permutations sought is 10! = 907200. and T1 T2 can be permuted in 2! ways. T. In A. U. which can be permuted in 13! different ways by Theorem 254. n1 !n2 ! · · · nk ! 261 Example In how many ways may we permute the letters of the word MASSACHUSET T S in such a way that MASS is always together. 2. 1 ≤ a ≤ b ≤ c ≤ 7 and we ﬁnd the permutations of each triplet. 4. S1 S2 S3 S4 can be permuted in 4! ways. C. 3. We have (a. T. in this order? Solution: The particle MASS can be considered as one block and the 9 letters A. 3. E. for example.

keeping the vowels in their natural order and not letting the two F’s come together? 9! ways of permuting the letters of AFFECTION. 264 Example In how many ways can the letters of the word AFFECTION be arranged. and in only one of these 2! 9! ways of permuting the letters of AFFECTION in which their vowels keep their will they be in their natural order. observe the boundary conditions n n n n = = 1. Also. 5 7 64 . k be non-negative integers with 0 ≤ k ≤ n. = 55. 267 Example 11 11 = = 55. 11¡ 2 12¡ 7 12·11·10·9·8·7·6 1·2·3·4·5·6·7 110¡ 109 110. 9 2 12 12 = = 792. The 4 vowels can be permuted in 4! ways. = = n. This 8 · 7! means that there are 8 · 7! permutations of AFFECTION that keep the two F’s together.2. In conclusion. This creates 8 spaces in between them where we put the two F’s. choosing k of them out of the hat is the same as choosing n − k of them to remain in the hat. we have for integer n. Thus the number of ways sought is 3 · 2 · 5 = 30. 0 ≤ k ≤ n. Hence there are permutations of 4! AFFECTION where the vowels occur in their natural order.64 Chapter 6 In the ﬁrst case there are 2! = 2 of putting the remaining M and U. = 792. Thus there are 2!4! natural order. and the second in 2 ways. we can choose the ﬁrst letter of the word in 3 ways. the symmetry identity n n! n n! = = = k k!(n − k)! (n − k)!(n − (n − k))! n−k . k. there are k factors in both the numerator and denominator. put the 7 letters of AFFECTION which are not the two F’s. 110¡ 0 Since n − (n − k) = k. k k!(n − k)! 1· 2· 3··· k Observe that in the last fraction.3 Combinations without Repetitions 265 Deﬁnition Let n. Solution: There are Now. in the second there are 2! = 2 and in the third there is only 1!. 1. This can be interpreted as follows: if there are n different tickets in a hat. 0 n 1 n−1 266 Example We have 6¡ 3 = = = = = 6·5·4 1·2·3 11·10 1·2 = 20. the number of permutations sought is 9! 8 · 7! 8! − = 2!4! 4! 4! 9 8 · 7 · 6 · 5 · 4! 7 −1 = · = 5880 2 4! 2 6. In the general case. Thus starting the word with MU gives 2 + 2 + 1 = 5 possible arrangements. The symbol n (read “n choose k”) is deﬁned and denoted by k n n! n · (n − 1) · (n − 2) · · · (n − k + 1) = = .

Then the numbers of k-combinations of these n objects is Proof: Pick any of the k objects. . . Z.W } are XY. k! k u 272 Example From a group of 10 people. 20} there are 6 7 7 numbers leaving remainder 0 numbers leaving remainder 1 numbers leaving remainder 2 The sum of three numbers will be divisible by 3 when (a) the three numbers are divisible by 3.Y. XZW. we may choose a committee of 4 in 10 = 210 ways.Combinatorial Methods 268 Deﬁnition Let there be n distinguishable objects. A k-combination is a selection of k. They can be ordered in n(n − 1)(n − 2) · · · (n − k + 1). 2. Hence the total number of k-combinations is n(n − 1)(n − 2) · · · (n − k + 1) n = . .Y Z. etc. 4 273 Example Three different integers are drawn from the set {1. . .Y. k 271 Theorem Let there be n distinguishable objects.3: Example 274. XYW. XZ. Hence the number of ways is 6 6 + 3 1 7 1 7 7 7 + + = 384. one leaves remainder 1 and the third leaves remainder 2 upon division by 3. . . 0 ≤ k ≤ n.YW Z. n − 1 ways of choosing the second. 1 3 3 B O B A A Figure 6. n . (c) all three leave remainder 1 upon division by 3. Z.YW. (d) all three leave remainder 2 upon division by 3. In how many ways may they be drawn so that their sum is divisible by 3? Solution: In {1. 269 Example The 2-combinations from the list {X. 65 .W Z. and let k. This particular choice of k objects can be permuted in k! ways. since there are n ways of choosing the ﬁrst. (0 ≤ k ≤ n) objects from the n made without 65 regards to order. 20}. . 270 Example The 3-combinations from the list {X.4: Example 275.W } are XY Z. (b) one of the numbers is divisible by 3. XW. 2. Figure 6.

3 observe that any shortest path must consist of 6 horizontal moves and 3 vertical ones for ¡ total of 6 + 3 = 9 moves. r−1 Proof: Write n as where there are n 1s and n − 1 +s. The equation x1 − 1 + x2 − 1 + · · · + xr − 1 = n is equivalent to which from Theorem 276.2. r−1 Proof: Put xr − 1 = yr . Then xr ≥ 1.4 Combinations with Repetitions 276 Theorem (De Moivre) Let n be a positive integer. We are seeking integral solutions to a + b + c = 9. 6 275 Example To count the number of shortest routes from A to B in ﬁgure 6. so. The number of positive integer solutions to x1 + x2 + · · · + xr = n is n−1 . 3 279 Corollary Let n be a positive integer. n = 1 + 1 + · · · + 1 + 1. for example. By Theorem 276 this is 9−1 8 = = 28. c > 0. which by Theorem 276 is 99 = 156849.66 Chapter 6 274 Example To count the number of shortest routes from A to B in ﬁgure 6. Of these 9 moves once we choose the 6 horizontal ones the 3 vertical ones are a determined. 3−1 2 278 Example In how many ways can 100 be written as the sum of four positive integer summands? Solution: We want the number of positive integer solutions to a + b + c + d = 100. Thus the desired number of paths is 3 3 5¡ 4¡ = (20)(4) = 80. a > 0. Solution: Notice that this is example 262. b > 0. u 66 . To decompose n in r summands we only need to choose r − 1 pluses from the n − 1. u 277 Example In how many ways may we write the number 9 as the sum of three positive integer summands? Here order counts. Thus there are 9 = 84 paths. 1 + 7 + 1 is to be regarded different from 7 + 1 + 1. n+r−1 r−1 solutions. has x1 + x2 + · · · + xr = n + r. which proves the theorem. The number of non-negative integer solutions to y1 + y2 + · · · + yr = n is n+r−1 .4 that pass through¡ ¡ point O we count the number of paths from A to O (of which there are 5 = 20) and the number of paths from O to B (of which there are 4 = 4). 3 3 6.

282 Example Find the number of quadruples (a. c.5. How many among the 40 neither smoke nor chew? Solution: Let A denote the set of smokers and B the set of chewers. d ≥ 1. By Theorem 276 this number is 49 = 18424. Solution: The number of non-negative solutions to a + b + c + d ≤ 2001 equals the number of solutions to a + b + c + d + f = 2001 where f is a non-negative integer. in A ∩ B). . In this section we will drop the disjointness requirement and obtain a formula for the cardinality of unions of general ﬁnite sets. By Corollary 279 there are 10+3−1¡ 3−1 = 12¡ 2 a ≥ 0.3 Inclusion-Exclusion The Sum Rule 240 gives us the cardinality for unions of ﬁnite sets that are mutually disjoint. and by R3 the number of elements which are B but not in A (i. b ≥ 0. which proves the theorem. in A \ B).. 67 . d) of integers satisfying 67 a + b + c + d = 100. b > 21. It is also known that 10 both smoke and chew.. u 284 Example Of 40 people. 6. that is. We have R1 + R2 + R3 = card (A ∪ B).e. Then we want the number of positive integer solutions to a + 29 + b + 21 + c + d = 100. b.e. Then card (A ∪ B) = card (A) + card (B) − card (A ∩ B) = 28 + 16 − 10 = 34. we mark by R1 the number of elements which are simultaneously in both sets (i. c ≥ 1. c. = 66 such solutions. or a + b + c + d = 50. by R2 the number of elements which are in A but not in B (i. The Principle of Inclusion-Exclusion is attributed to both Sylvester and to Poincar´ . We need a decomposition of the form 210 = 2a 2b 2c . b. Solution: Put a + 29 = a. c ≥ 0. in B \ A).Inclusion-Exclusion 280 Example Find the number of quadruples (a. This number is the same as the number of positive integer solutions to which is easily seen to be 2005¡ 4 a1 − 1 + b1 − 1 + c1 − 1 + d1 − 1 + f1 − 1 = 2001. a ≥ 30.. b + 20 = b. we need integers solutions to a + b + c = 10.e. 3 281 Example In how many ways may 1024 be written as the product of three positive integers? Solution: Observe that 1024 = 210 . d) of non-negative integers which satisfy the inequality a + b + c + d ≤ 2001. 28 smoke and 16 chew tobacco. e 283 Theorem (Two set Inclusion-Exclusion) card (A ∪ B) = card (A) + card (B) − card (A ∩ B) Proof: In the Venn diagram 6.

We want card (A \ (A3 ∪ A5 )) = card (A) − card (A3 ∪ A5 ) = 57 − 30 = 27. . Notice that 90 = 30(3). 110}. 114}. Thus card (A3 ) = 19. Notice that the elements are 2 = 2(1). . . We have accounted for 10 + 18 + 6 = 34 people that are in at least one of the set. 6. 4.6 as follows. They are {6.68 Chapter 6 meaning that there are 34 people that either smoke or chew (or possibly both). 12. 6 A R2 R1 R3 B A 18 8 6 B Figure 6. 20. They are {10. . 57 3 There are = 19 integers in A divisible by 3. 90}. 4 = 2(2). Solution: Let A3 ⊂ A be the set of those integers divisible by 3 and A5 ⊂ A be the set of those integers divisible by 5. They are {30. . Notice that 110 = 10(11). . Aliter: We ﬁll up the Venn diagram in ﬁgure 6. 114 = 2(57). 68 . There are 57 5 = 11 integers in A divisible by 5. We want card (A3 ∪ A5 ) = 19 + 11 = 30. and observe that 15 by Theorem ?? we have card (A15 ) = card (A3 ∩ A5 ). 5 or both? How many are neither divisible by 3 nor 5? How many are divisible by exactly one of 3 or 5? A = {2. . Thus card (A15 ) = 3. Since |A ∩ B| = 8. The remaining 40 − 34 = 6 are outside the sets. 18. . we put an 10 in the intersection. 285 Example Consider the set How many elements are there in A? How many are divisible by 3? How many are divisible by 5? How many are divisible by 15? How many are divisible by either 3. .6: Example 284. Thus card (A) = 57. . 60. Therefore the number of people that neither smoke nor chew is 40 − 34 = 6. 114}. . Notice that 114 = 6(19). 30. . Thus card (A5 ) = 11 There are 57 = 3 integers in A divisible by 15. . . . .5: Two-set Inclusion-Exclusion Figure 6. Then we put a 28 − 10 = 18 in the part that A does not overlap B and a 16 − 10 = 6 in the part of B that does not overlap A. We want card ((A3 ∪ A5 ) \ (A3 ∩ A5 )) = = = card ((A3 ∪ A5 )) − card (A3 ∩ A5 ) 30 − 3 27.

2 1000 1000 = 200. 69 . 1000] then clearly card (A2 ) = = 500. Similarly. C R4 R6 A R2 R3 R5 R7 R1 B Figure 6. This means that if A5 denotes the set of those integers divisible by 5 then card (A5 ) = 5 10 there are card (A2 ∪ A5 ) = 500 + 200 − 100 = 600 integers in the interval [1. 1000] that do not share a factor prime factor with 1000. We now derive a three-set version of the Principle of Inclusion-Exclusion. are relatively prime to 69 1000? Solution: Observe that 1000 = 23 53 .7: Three-set Inclusion-Exclusion 287 Theorem (Three set Inclusion-Exclusion) card (A ∪ B ∪C) = card (A) + card (B) + card (C) −card (A ∩ B) − card (B ∩C) − card (C ∩ A) +card (A ∩ B ∩C) Proof: Using the associativity and distributivity of unions of sets. Also card (A2 ∩ A5 ) = = 100. that is. thus there are 1000 − 600 = 400 integers in [1. do not share a common factor with 1000. 1000] sharing at least a factor with 1000. we see that card (A ∪ B ∪C) = = = = card (A ∪ (B ∪C)) card (A) + card (B ∪C) − card (A ∩ (B ∪C)) card (A) + card (B ∪C) − card ((A ∩ B) ∪ (A ∩C)) card (A) + card (B) + card (C) − card (B ∩C) −card (A ∩ B) − card (A ∩C) +card ((A ∩ B) ∩ (A ∩C)) = card (A) + card (B) + card (C) − card (B ∩C) − (card (A ∩ B) + card (A ∩C) − card (A ∩ B ∩C)) = card (A) + card (B) + card (C) −card (A ∩ B) − card (B ∩C) − card (C ∩ A) +card (A ∩ B ∩C) . If A2 denotes the set of those integers divisible by 2 in the interval [1. and thus from the 1000 integers we must weed out those that have a factor of 2 or of 5 in their prime 1000 factorisation.Inclusion-Exclusion 286 Example How many integers between 1 and 1000 inclusive.

289 Example In a group of 30 people. 12 speak Spanish and 10 speak French. We ﬁll-up the Venn diagram in ﬁgure 6. In the region common to A and B which is not ﬁlled up we put 5 − 2 = 3. 600] which are divisible by k = 3. Figure 6. The number of people speaking all three languages is 3.8: Example 289. C 1 2 3 A 1 2 without a 7 without a 9 9550 4 3 B 14266 14406 9550 14266 14266 9550 without an 8 Figure 6. 5. See also ﬁgure 6. It is known that 5 speak English and Spanish. 8 speak English. 600] divisible by at least one of 3. How many are there? 2. Then card (A3 ) card (A5 ) card (A7 ) card (A15 ) card (A21 ) card (A35 ) card (A105 ) = = = = = = = 600 3 600 5 600 7 600 15 600 21 600 35 600 105 = = = = = = = 200. 120.8 successively. How many have exactly three 9’s? 70 . B the set of Spanish speakers and C the set of French speakers in our group. devoid of any element belonging to A ∪ B ∪C). How many do not have a 9 in their decimal representation? 3. nor 5. 290 Example Consider the set of 5-digit positive integers written in decimal notation. and in the remaining part of C we put 10 − 2 − 3 − 4 = 1. 5. we put 7 − 3 = 4. How many have exactly one 9? 5. u Chapter 6 Observe that in the Venn diagram in ﬁgure 6. 85.9: Example 290. In the region common to A and C which is not already ﬁlled up we put 5 − 3 = 2.7 there are 8 disjoint regions (the 7 that form A ∪ B ∪C and the outside region. In the remaining part of A we put 8 − 2 − 3 − 2 = 1. 40 28 17 5 By Inclusion-Exclusion there are 200 + 120 + 85 − 40 − 28 − 17 + 5 = 325 integers in [1. Those not divisible by these numbers are a total of 600 − 325 = 275.7. How many have at least one 9 in their decimal representation? 4. nor 7? Solution: Let Ak denote the numbers in [1. or 7. How many do not speak any of these languages? Solution: Let A be the set of all English speakers. and 7 English and French. Those outside these three sets are then 30 − 16 = 14. in the remaining part of B we put 12 − 4 − 3 − 2 = 3. Each of the mutually disjoint regions comprise a total of 1 + 2 + 3 + 4 + 1 + 2 + 3 = 16 persons. 288 Example How many integers between 1 and 600 inclusive are not divisible by neither 3. How many have exactly two 9’s? 6. In the intersection of all three we put 8. 5 Spanish and French. 1. 7.70 This gives the Inclusion-Exclusion Formula for three sets. In the region common to B and C which is not already ﬁlled up.

Altogether there are 36 + 8 = 44 ﬁve-digit positive integers with exactly three 9’s in their decimal representation. If the ﬁrst digit is not a¡ then there 9. How many have neither a 7. How many have either a 7. then there are 8 choices for this ﬁrst digit. we have 4 = 6 ways of choosing 2 where the two 9’s will be. are there given the following constraints: 1 ≤ a ≤ 10. Thus in this case there are 8 · 4 · 9 = 288 such numbers. an 8. c ≥ 2. d ≥ 31. We have 7 choices for the ﬁrst digit and 8 choices for the remaining 4 digits. we have 4 = 4 ways of 3 choosing where the three 9’s will be. are 8 choices for this ﬁrst digit. How many integral solutions to the equation a + b + c + d = 100. or a 9 in their decimal representation? ¡ place can be accomplished in 4 = 6 ways. We have 6 choices for the ﬁrst digit and 7 choices for the remaining 4 digits. c ≥ 2. Also. a ≥ 1. There are 80¡ 3 = 82160 integral solutions to a + b + c + d = 100. giving 94 = 6561 such numbers. If the ﬁrst digit is not a 9. giving 4 · 93 = 2916 such numbers. 2. 7. The other remaining digit must be different from 9. We use inclusion-exclusion. If the ﬁrst digit is a 9 then three of the remaining four must be ¡ 9’s. How many have neither an 8 nor a 9 in their decimal representation? Solution: 1.Inclusion-Exclusion 7. 9. giving 4 · 9 = 36 such numbers. There are 9 possible choices for the ﬁrst digit and 10 possible choices for the remaining digits. We condition on the ﬁrst digit. card (B) = 3 . Again we condition on the ﬁrst digit. nor an 8. nor a 9 in their decimal representation? 11. Thus in this case there are 8 · 1 = 8 such numbers. 4. Thus in this case there are 8 · 6 · 92 = 3888 such numbers. There is obviously only 1 such positive integer. c ≥ 2. Altogether there are 486 + 288 = 774 ﬁve-digit positive integers with exactly three 9’s in their decimal representation. b ≥ 0. The other three remaining 1 digits must be different from 9. If the ﬁrst digit is not a 9. 10. Altogether there are 2916 + 3888 = 6804 ﬁve-digit positive integers with exactly two 9’s in their decimal representation. d ≥ 20. Observe that 37512 = 29889 + 6804 + 774 + 44 + 1. The number of choices is thus 9 · 104 = 90000. The difference 90000 − 52488 = 37512. Also. and we have 9 ways of ﬁlling the remaining spot. card (A ∩ B) = 3 and so card (A ∪ B) = 70 69 59 + − = 74625. we have 4 = 4 ways 1 of choosing where the 9 will be. There are 8 possible choices for the ﬁrst digit and 9 possible choices for the remaining digits. and the choice of 291 Example 71 10. Thus the desired number is 90000 − 85854 = 4146. If the ﬁrst digit is a 9 then two of the remaining four must be 9’s. Let A be the set of solutions with and B be the set of solutions with Then card (A) = a ≥ 11. thus ﬁlling all the spots. b ≥ 0. How many have exactly ﬁve 9’s? 9. and we have 93 ways of ﬁlling the 3 remaining spots. giving 6 · 92 = 486 such numbers. The number of choices is thus 8 · 94 = 52488. 8. 69¡ 59¡ . ¡ there are 8 then choices for this ﬁrst digit. d ≥ 20 70¡ 3 a ≥ 1. 5. and we have 92 ways of ﬁlling the two remaining spots. Also. We condition on the ﬁrst digit. 20 ≤ d ≤ 30? Solution: We use Inclusion-Exclusion. If the ﬁrst digit is a 9 then one of the remaining four must be a 9. c ≥ 2. giving 6 · 74 = 14406 such integers. Thus in this case there are 8 · 4 · 93 = 23328 such numbers. 11.9. In total there are 6561 + 23328 = 29889 ﬁve-digit positive integers with exactly one 9 in their decimal representation. 3 3 3 a + b + c + d = 100 The total number of solutions to 71 . the numbers inside the circles add up to 85854. b ≥ 0. and the choice of place can be accomplished in 4 = 4 3 ways. If the ﬁrst digit is not a ¡ 9. giving 7 · 84 = 28672 such integers. From ﬁgure 6. If the ﬁrst digit is a 9 then the other four remaining digits must be different from 9. 6. The other two 2 remaining digits must be different from 9. 3. Also. How many have exactly four 9’s? 8. and the choice of place can ¡ be accomplished in 4 = 4 ways. then there are 8 choices for this ﬁrst digit. b ≥ 0. we have 4¡ 4 = 4 ways of choosing where the four 9’s will be.

each digit in the number appears at least thrice. but the phone number must be odd. 4. 5550000. Find the number of telephone numbers possible that meet the following criteria: You may repeat all digits. 22. 20 ≤ d ≤ 30 is thus 80 70 69 59 − − + = 7535. 3. 33. 1 + 2. 293 Problem The number 3 can be expressed as a sum of one or more positive integers in four ways. 294 Problem Let n = 231 319 . 1. Shew that any positive integer n can be so expressed in 2n−1 ways. 302 Problem In each of the 7-digit numbers 1001011. and the only digits available are {0. 4. 9. 5. You may not repeat any of the digits. How many positive integer divisors of n2 are less than n but do not divide n? 295 Problem In how many ways can one decompose the set {1.C satisfying A ∪ B ∪C = {1. You may not repeat the digits and the phone numbers must be odd.72 with 1 ≤ a ≤ 10. 1 or 5. 8}. 2 + 1. Find the 1984-th positive palindrome. Find the number of such 7-digit natural numbers. . as 3. each digit in the number appears at least twice. Find S. . c ≥ 2. 3 3 3 3 Chapter 6 Homework 292 Problem Telephone numbers in Land of the Flying Camels have 7 digits. 300 Problem (AIME 1994) Given a positive integer n. You may repeat the digits. (If n has only one digit. 707099. 2. then p(n) is equal to that digit. 118818. 100} into subsets A. b ≥ 0. . but the phone number must be even. . . You may repeat the digits. namely. 5. 3838383. 2. No telephone number may begin in 0. starting with 1 is written in ascending order 1. 301 Problem In each of the 6-digit numbers 333333. 7777777. .) Let S = p(1) + p(2) + · · · + p(999). . 2. B. . 100} and A ∩ B ∩C = ∅? 296 Problem How many two or three letter initials for people are available if at least one of the letters must be a D and one allows repetitions? 297 Problem How many strictly positive integers have all their digits distinct? 298 Problem To write a book 1890 digits were utilised. 7. . 6. and 1 + 1 + 1. How many pages does the book have? 299 Problem The sequence of palindromes. 3. 8. let p(n) be the product of the non-zero digits of n. 11. 225522. 72 . 7. 3. Find the number of such 6-digit natural numbers. 2. . 3. .

20% like only the movies. and single? 306 Problem In Medieval High there are forty students. nor theology. The policyholders can also be classiﬁed as 1320 young males. All three subjects are favoured by four students. playing sports. Each policy holder is classiﬁed as • young or old. How many of the company’s policyholders are young. One either erases or keeps a plus sign. fourteen like Mathematics. and at least 85% a leg. and eleven like alchemy.) In a very hotly fought battle. We condition on the last digit. female. while 310 like all three? State your reasons! 304 Problem A survey shews that 90% of high-schoolers in Philadelphia like at least one of the following activities: going to the movies. For if n2 = ab. Thus the total number of phone numbers is 7200 + 5760 = 12960. Of these policyholders. and 35% like reading. 723 like ice cream. and 7000 are married. Also. it is known that 12% like both the movies and reading. If the last digit were 1 or 5 then we would have 5 choices for the ﬁrst digit. nor alchemy? 307 Problem (AHSME 1991) For a set S. at least 80% an arm. B. then we would have 4 choices for the last digit and so we would have 4 · 6 · 5 · 4 · 3 · 2 · 2 = 5760 phone numbers. 3010 married males. If A. This is 5 · 85 · 4 = 655360. there is exactly one decomposition n2 = n · n. at least 70% of the combatants lost an eye. let n(S) denote the number of subsets of S. 48% like sports. then b < n. 463 like both candy and cake. 293 n = 1 + 1 + · · · + 1. 816 like candy. are sets for which n(A) + n(B) + n(C) = n(A ∪ B ∪C) and card (A) = card (B) = 100. What can be said about the percentage who lost all four members? Answers 292 We have This is 5 · 86 = 1310720. with a > n. and 15% only reading. because otherwise n2 = ab > n · n = n2 . Amongst them. Finally. 4600 are male. or reading. What percent of high-schoolers like all three activities? 305 Problem An auto insurance company has 10. It is also known that seven like Mathematics and theology. a contradiction. How many students like neither Mathematics. Thus the desired number is d(n2 ) (63)(39) + 1 − d(n) = + 1 − (32)(20) = 589. The easiest way to see this is to observe that there is a bijection between the divisors of n2 which are > n and those < n. and 1400 young married persons. eight like theology and alchemy and ﬁve like Mathematics and alchemy. and • married or single. Also. at least 75% an ear.C. This is 5 · 7 · 6 · 5 · 4 · 3 · 2 = 25200. It is known that 45% like the movies. This is 5 · 85 · 4 = 655360. then what is the minimum possible value of card (A ∩ B ∩C)? 308 Problem (Lewis Carroll in A Tangled Tale. 2 2 73 . 470 both ice cream and cake. 645 cake.Answers 73 303 Problem Would you believe a market investigator that reports that of 1000 people. 600 of the policyholders are young married males. and so we would have 5 · 6 · 5 · 4 · 3 · 2 · 2 = 7200 phone numbers. 3000 are young. 000 policyholders. while 562 like both candy and ice cream. • male or female. sixteen like theology. ßÞ n−1 + s 294 There are 589 such values. If the last digit were either 3 or 7.

If 0 is not used. two of each kind. 9 8 · = 1080 integers in category 2 1 1 3!3! 2!4! 74 . (IV) there are exactly three different digits used. (III) there are exactly two different digits used. constitutes the 9 + 9 + 90 + 90 + 900 + 900 = 1998th palindrome. The last palindrome with 6 digits. 1 · 9 + 2 · 90 = 189 301 The numbers belong to the following categories: (I) all six digits are identical. the 1994th is 995599. 90 with 3-digits.7 and R3 will be empty. The book has 99 + 567 = 666 pages. 300 If x = 0. the 1995th palindrome is 996699. (II) there are exactly two different digits used. we must consider the cases when ¡ 6! ¡ ¡ 6! the digit 0 is used or not. then clearly p(100a + 10b + c) = m(a)m(b)m(c). which in turn = = = = Hence S = = = = p(001) + p(002) + · · · + p(999) 97336 − p(000) 97336 − m(0)m(0)m(0) 97335. To each of the 100 numbers we may thus assign one of 6 labels. three of one kind. two of one kind. put m(x) = 1. then there are 9 · = 720 integers in category (II). the 1996th palindrome is 997799. 90 with 4-digits. To count the numbers in the remaining categories. 900 with 5-digits and 900 with 6-digits.. inclusive. There are clearly 9 numbers belonging to category (I). four of the other.74 Chapter 6 295 The conditions of the problem stipulate that both the region outside the circles in diagram 6. Thus p(000) + · · · + p(999) = m(0)m(0)m(0) + · · · + m(9)m(9)m(9). We are thus left with 6 regions to distribute 100 numbers. the 1997th palindrome is 998899. 999999. until we ﬁnd the 1984th palindrome to be 985589. The number of sets thus required is 6100 . Hence. c are digits. otherwise put m(x) = x. 296 (262 − 252 ) + (263 − 253 ) = 2002 297 9+9·9 +9 · 9 · 8 + 9 · 9 · 8 · 7 +9 · 9 · 8 · 7 · 6 + 9 · 9 · 8 · 7 · 6 · 5 +9 · 9 · 8 · 7 · 6 · 5 · 4 + 9 · 9 · 8 · 7 · 6 · 5 · 4 · 3 +9 · 9 · 8 · 7 · 6 · 5 · 4 · 3 · 2 +9 · 9 · 8 · 7 · 6 · 5 · 4 · 3 · 2 · 1 = 8877690 298 A total of digits are used to write pages 1 to 99. three of the other. (m(0) + m(1) + · · · + m(9))3 (1 + 1 + 2 + · · · + 9)3 463 97336. 9 palindromes with 2-digits. 299 It is easy to see that there are 9 palindromes of 1-digit. b. from 000 to 999 If a. We use three digits to label all the integers. etc. We have of 1890 − 189 = 1701 digits at our disposition which is enough for 1701/3 = 567 extra pages (starting from page 100).

and K denote the set of people who like cake. respectively. We have card (Y ∩ F ∩ S) = = card (Y ∩ F) − card (Y ∩ F ∩ Ma) card (Y ) − card (Y ∩ M) −(card (Y ∩ Ma) − card (Y ∩ Ma ∩ M)) = = 3000 − 1320 − (1400 − 600) 880. (II) there are exactly two different digits used. card (C ∩ K) = 463. then there are 9 8 · = 2520 integers in category (II). There are 9 · = 90 in 1 2!2!2! 2!3! 9¡ 5! 9¡ 5! 5! + ) = 135 in category (III) . card (I) = 723. then the integers may not start with 0. 302 The numbers belong to the following categories: (I) all seven digits are identical. we must consider the cases when ¡ ¡ 7! the digit 0 is used or not. To count the numbers in the remaining category (II). then the integers may not 1 1 3!4! 9¡ 6! 9¡ 6! + 1 · = 315 in category (II). The investigator miscounted. F. M stand for young. 1 · ( 1!4! 3!2! 1!2!2! (III). If 0 is not used. 305 Let Y. card (C ∩ I) = 562. 304 We make the Venn diagram in as in ﬁgure 6. 75 . three of one kind. If 0 is used. By Inclusion-Exclusion we have card (C ∪ I ∪ K) = card (C) + card (I) + card (K) −card (C ∩ I) − card (C ∩ K) − card (I ∩C) +card (C ∩ I ∩ K) = = 816 + 723 + 645 − 562 − 463 − 470 + 310 999. S. four of the other. single. There are 1 · 2!4! 3!3! 303 Let C denote the set of people who like candy. Thus there are altogether category (II) . card (I ∩ K) = 470.10. female. or probably did not report one person who may not have liked any of the three things. y = 7. card (K) = 645. We are given that card (C) = 816. and card (C ∩ I ∩ K) = 310. If 0 is used. male. z = 13. start with 0. and let Ma stand for married. Thus there are altogether 2520 + 315 + 9 = 2844 such integers. and 3 75 9 ¡ · 9 + 720 + 1080 + 7560 + 90 + 135 + 3240 = 12834 such integers. and 2 · 2 · = 3240 in category (IV). There are clearly 9 numbers belonging to category (I). From it we gather the following system of equations x x x x x + + + y y y + z + t + u + 15 + 20 + y + + z z + + t t + u + 15 + 20 = = = = = 45 48 35 12 90 The solution of this system is seen to be x = 5.Answers ¡ 5! 6! = 7560 integers in category (IV). Thus the percent wanted is 5%. u = 22. I the set of people who like ice cream. t = 8.

card (A ∩ B) ≥ . . .45n + . By the Principle of Inclusion-Exclusion. B the set of students liking theology. 2. ¡ card A ∩ B ∩ C = 40 − card (A) − card (B) − card (C) + card (A ∩ B) + card (A ∩C) + card (B ∩C) − card (A ∩ B ∩C) Substituting the numerical values of these cardinalities 40 − 14 − 16 − 11 + 7 + 5 + 8 − 4 = 15. card (A ∩ B) = 7. 6. . C = {1. card (A ∩C) = 5. . and C be the set of students liking alchemy. . card (C) = 11. 102}. Suppose there are n combatants. Using the Principle Inclusion-Exclusion.65n. 2. B = {3. . A ∪C. As A ∪ B. We are given that card (A) = 14. C denote those who lost an arm and D denote those losing a leg. Hence card (A ∪ B ∪C) = 102.65n − card (A ∩ B ∩C ∩ D) . The example and A = {1.8n + .75n − card (A ∩ B) . 3. card (A ∩ B ∩C) = = card (A ∩ B) + card (A ∩C) + card (B ∩C) − 199 (card (A) + card (B) − card (A ∪ B)) + (card (A) + card (C) − card (A ∪C)) +(card (B) + card (C) − card (B ∪C)) − 199 = 403 − card (A ∪ B) − card (A ∪C) − card (B ∪C) . as 1 + 2card(C)−101 is larger than 1 and a power of 2. Thus card (A ∩ B ∩C) = 403 − card (A ∪ B) − card (A ∪C) − card (B ∪C) ≥ 403 − 3 · 102 = 97. We are given 2100 + 2100 + 2card(C) = 2card(A∪B∪C) . 100}. 308 Let A denote the set of those who lost an eye.76 Chapter 6 306 Let A be the set of students liking Mathematics. . 101. 307 A set with k elements has 2k different subsets. . card (B) = 16. 5. and card (A ∩ B ∩C) = 4. 6. card (A ∪ B) card (A) + card (B) − card (A ∩ B) . . n ≥ = ≥ card ((A ∩ B) ∪ (C ∩ D)) card (A ∩ B) + card (C ∩ D) − card (A ∩ B ∩C ∩ D) . B denote those who lost an ear. .85n − card (C ∩ D) . This means that 76 . Then n ≥ = = n ≥ = = This gives card (C ∩ D) ≥ .7n + . the cardinalities of all these sets are ≤ 102. 4. since card (A) + card (B) + card (C) − card (A ∪ B ∪C) = 199. . . card (B ∩C) = 8. . 4. 5. card (C ∪ D) card (C) + card (D) − card (C ∩ D) .45n. . . This forces card (C) = 101. 100}) = 97 is attainable. B ∪C ⊆ A ∪ B ∪C. 102} shews that card (A ∩ B ∩C) = card ({4. .

This means that at least 10% of the combatants lost all four members.Answers whence card (A ∩ B ∩C ∩ D) ≥ . 77 .45 + .10: Problem 304. 77 Sports u z x Movies 20 y 15 Reading t Figure 6.1n.65n − n = .

what is the resulting sum? Solution: This is asking for the product (10 + 11 + · · · + 20)(21 + 22 + · · · + 30) after all the terms are multiplied.1) Applying Gauss’s trick to the general arithmetic sum (a) + (a + d) + (a + 2d) + · · · + (a + (n − 1)d) we obtain (a) + (a + d) + (a + 2d) + · · · + (a + (n − 1)d) = n(2a + (n − 1)d) 2 (7. 30}. that is. .1 Famous Sums To obtain a closed form for we utilise Gauss’ trick: If An = 1 + 2 + 3 + · · · + n then An = n + (n − 1) + · · · + 1. Adding these two quantities. . 11. 23. 2 1+2+··· +n = n(n + 1) . . 22. 19. An An 2An = = = = since there are n summands. . But 10 + 11 + · · · + 20 = and 21 + 22 + · · · + 30 = The required total is (165)(255) = 42075. . 2 78 . 29. . . + + + 2 (n − 1) (n + 1) + + + ··· ··· ··· + + + n 1 (n + 1) n(n + 1) . 12.Chapter 7 1+2+··· +n = n(n + 1) 2 Sums and Recursions 7. (20 + 10)(11) = 165 2 (30 + 21)(10) = 255. This gives An = 1 n (n + 1) n(n + 1). . 2 (7. 20} is multiplied by each element of the set {21. If all these products are added.2) 309 Example Each element of the set {10.

2S = 2 + 4 + 8 + · · · + 1024 + 2048. But this is 16 16 16 (6r + 2) = 6 r=0 r=0 r+ r=0 2=6 16(17) + 2(17) = 850. . 312 Example Find the geometric sum x= Solution: We have Then 2 3x 1 1 1 1 + 2 + 3 + · · · + 99 .3) a + ar + · · · + arn−1 = (7. . 2 A geometric progression is one of the form a. . r = 0. 1−r a − arn 1−r a 1−r (7. . . Hence From this we deduce that S − rS = a + ar + ar2 + · · · + arn−1 − ar − ar2 − · · · − arn = a − arn .4) 79 . For |r| < 1. S= that is. . 1. arn−1 .Famous Sums 310 Example Find the sum of all integers between 1 and 100 that leave remainder 2 upon division by 6. if r = 1 then S = na. S = 2S − S = (2 + 4 + 8 · · · + 2048) − (1 + 2 + 4 + · · · + 1024) = 2048 − 1 = 2047. . ar3 . 311 Example Find the following geometric sum: 1 + 2 + 4 + · · · + 1024. 16. so we may assume that r = 1. rS = ar + ar2 + · · · + arn . − 2 2 · 399 Plainly. x= Let us sum now the geometric series 1 1 . . we obtain the sum of the inﬁnite geometric series a + ar + ar2 + · · · = a − arn . ar2 . . . . If |r| < 1 then rn → 0 as n → ∞. 3 3 3 3 1 1 1 1 1 x = 2 + 3 + · · · + 99 + 100 . . 3 3 3 3 3 = = x− 1x 3 1 1 1 ( 3 + 32 + 33 + · · · + 31 ) 99 1 1 1 −( 32 + 33 + · · · + 31 + 3100 ) 99 = From which we gather 1 3 1 − 3100 . Solution: Let Then Hence S = 1 + 2 + 4 + · · · + 1024. ar. We have S = a + ar + ar2 + · · · + arn−1 . 79 Solution: We want the sum of the integers of the form 6r + 2.

= 2·1−1 2·2−1 2·3−1 . n2 − (n − 1)2 Adding both columns. . Solving for the sum. 2 8 32 5 1 − −1 4 1− 4 Therefore. 1/2 unit right. .80 Chapter 7 313 Example A ﬂy starts at the origin and goes 1 unit up. . 1/16 unit up. . 3 · n2 − 3 · n + 1 n3 − 03 = 3(12 + 22 + 32 + · · · + n2 ) − 3(1 + 2 + 3 + · · · + n) + n. . In what coordinates does it end up? Solution: Its x coordinate is Its y coordinate is 1 1 1 1 2 2 − + −··· = = . 32 − 22 = = = . . 1/4 unit down. Hence 13 − 03 23 − 13 . Solution: Observe that k2 − (k − 1)2 = 2k − 1. . From the preceding example 1 + 2 + 3 + · · · + n = ·n2 /2 + n/2 = n(n+1) 2 so 3 · n(n + 1) + n. 5 1 1 1 4 = . . 5 ). 33 − 23 = = = . 2·n−1 n2 − 02 = 2(1 + 2 + 3 + · · · + n) − n. From this 12 − 02 22 − 12 . 314 Example Find a closed formula for An = 1 + 2 + · · · + n. .. etc. which we have already computed using Gauss’ trick. . 2 n3 − 03 = 3(12 + 22 + 32 + · · · + n2 ) − 80 . . the ﬂy ends up in ( 2 . + −··· = −1 4 16 5 1− 4 We now sum again of the ﬁrst n positive integers. 2 12 + 22 + 32 + · · · + n2 . . = 3 · 12 − 3 · 1 + 1 3 · 22 − 3 · 2 + 1 . 1 + 2 + 3 + · · · + n = n2 /2 + n/2 = 315 Example Find the sum n(n + 1) . 3 · 32 − 3 · 3 + 1 n3 − (n − 1)3 Adding both columns. Solution: Observe that k3 − (k − 1)3 = 3k2 − 3k + 1. 1/8 unit left. ad inﬁnitum.

. . 1·2 2·3 3·4 99 · 100 Solution: Observe that 1 1 1 = − . 1 · 4 4 · 7 7 · 10 31 · 34 Solution: Observe that 1 1 1 1 1 = · − · . (3n + 1) · (3n + 4) · (3n + 7) 6 (3n + 1)(3n + 4) 6 (3n + 4)(3n + 7) 81 . 1 99·100 . 1 102 1 − 111 Summing both columns. k(k + 1) k k+1 1 1·2 1 2·3 1 3·4 Thus = = = . . .5) 1 1 1 1 + + +···+ .Famous Sums Solving for the sum. . . 3 2 3 n(n + 1)(2n + 1) 6 (7. 1·2 2·3 3·4 99 · 100 100 100 317 Example Add 1 1 1 1 + + +··· + . 12 + 22 + 32 + · · · + n2 = After simplifying we obtain 12 + 22 + 32 + · · · + n2 = 316 Example Add the series 81 n3 1 n + · n(n + 1) − . . 1 1 1 1 1 1 12 + + +··· + = − = . . 1 1 1 1 1 99 + + +··· + = 1− = . . = 1 1 1 2 1 3 −1 2 −1 3 −1 4 . 1 · 4 4 · 7 7 · 10 31 · 34 3 111 37 318 Example Sum 1 1 1 1 + + +···+ . 1 · 4 · 7 4 · 7 · 10 7 · 10 · 13 25 · 28 · 31 Solution: Observe that 1 1 1 1 1 = · − · . . (3n + 1) · (3n + 4) 3 3n + 1 3 3n + 4 1 1·4 1 4·7 1 7·10 1 10·13 Thus = = = = . 1 34·37 . = 1 3 1 − 12 1 − 21 1 − 30 1 − 39 1 12 1 21 1 30 . . 1 99 1 − 100 Adding both columns. .

1 6·25·28 1 − 6·28·31 Adding each column. 1 3 99 · 100 Adding each column. 1 25·28·31 . and un+4 + 9u2 = n5 n is of the fourth order. · 99 · 100 · 101 − 1 · 98 · 99 · 100 3 1 1 · 99 · 100 · 101 − · 0 · 1 · 2 = 333300. . 1 · 4 · 7 4 · 7 · 10 7 · 10 · 13 25 · 28 · 31 6 · 1 · 4 6 · 28 · 31 217 319 Example Find the sum 1 · 2 + 2 · 3 + 3 · 4 + · · · + 99 · 100. . 3 3 ·1·2·3− 1 ·0·1·2 3 ·2·3·4− 1 ·1·2·3 3 ·3·4·5− 1 ·2·3·4 3 . For example un+2 − un+1 = 2 is of the ﬁrst order. . A recurrence is linear if the subscripted letters appear only to the ﬁrst power. The equation xm+3 + 8xm+2 − 9xm = m2 − 3 82 . . 3 3 1 · 2 + 2 · 3 + 3 · 4 + · · · + 99 · 100 = 7. . . . Solution: Observe that Therefore 1·2 2·3 3·4 . = = = . . = 1 6·1·4 1 6·4·7 1 − 6·4·7 1 − 6·7·10 1 − 6·10·13 1 6·7·10 . = 1 3 1 3 1 3 1 1 k(k + 1) = (k)(k + 1)(k + 2) − (k − 1)(k)(k + 1). 1 1 1 1 1 1 9 + + +···+ = − = . For example un+2 − un+1 = 2 is a linear recurrence and x2 + nxn−1 = 1 and xn + 2xn−1 = 3 n are not linear recurrences. . Thus xm+3 + 8xm+2 − 9xm = 0 is homogeneous. A recursion is homogeneous if all its terms contain the subscripted variable to the same power. .2 First Order Recursions The order of the recurrence is the difference between the highest and the lowest subscripts.82 Therefore 1 1·4·7 1 4·7·10 1 7·10·13 Chapter 7 = = = . . .

n ≥ 1. Find a closed form for xn . . xn = 7 · 2n . 320 Example Let x0 = 7 and xn = 2xn−1 .First Order Recursions is not homogeneous. Test a solution of the form xn = Aan + g(n). . Also. . . A solution to the homogeneous equation will be of the form xn = A(2)n . Find a closed form for xn . . where f is a polynomial. . x = 2. So the solution is xn = 8(2n ) − 1 = 2n+3 − 1. . Aliter: We have x0 x1 x2 x3 . Now. 2A + B = 15. The solution is thus xn = 7(2)n . 2xn−1 Solution: By raising the subscripts in the homogeneous equation we obtain xn = 2xn−1 or x = 2. Aliter: We have: x0 x1 x2 x3 . 7 = x0 = A20 + B = A + B. = = 7 2x0 + 1 2x1 + 1 2x2 + 1 . Solution: Raising subscripts we have the characteristic equation xn = 2xn−1 . Solving the simultaneous equations A + B = 7. But 7 = x0 = A20 and so A = 7. Cancelling. 321 Example Let x0 = 7 and xn = 2xn−1 + 1. x1 = 2x0 + 7 = 15 and so 15 = x1 = 2A + B. a = 1. We outline a method for solving ﬁrst order linear recurrence relations of the form xn = axn−1 + f (n). xn Multiplying both columns. where g is a polynomial of the same degree as f . . = 7 2x0 2x1 2x2 . . xn−1 xn = = = = . . n ≥ 1. Cancelling this gives x = a. 2. 2xn−2 + 1 2xn−1 + 1 83 . The general solution will have the form xn = A2n + B. Thus we try a solution of the form xn = A2n . 83 A closed form of a recurrence is a formula that permits us to ﬁnd the n-th term of the recurrence without having to know a priori the terms preceding it. . we ﬁnd A = 8. This we call the characteristic equation. 1. The solution to the homogeneous equation xn = axn−1 will be of the form xn = Aan . Now f (n) = 1 is a polynomial of degree 0 (a constant) and so we test a particular constant solution C. where A is a constant to be determined. Cancelling the common factors on both sides of the equality. = = = = . were A is a constant. . x0 x1 · · · xn = 7 · 2n x0 x1 x2 · · · xn−1 . First solve the homogeneous recurrence xn = axn−1 by “raising the subscripts” in the form xn = axn−1 . B = −1.

. We thus solve the system 1 = A + D. x1 = 3(1) − 2 + 6 − 3 = 4. The general solution is xn = 2(9n ) + 7n. Finally. Aliter: Let un = xn + 1 = 2xn−1 + 2 = 2(xn−1 + 1) = 2un−1 . We thus solve the system 2 = A +C. Now x0 = 2. x1 = 9(2) − 56 + 63 = 25. Now f (n) = −2n2 + 6n − 3 is a polynomial of degree 2 and so we test a particular solution of the form Bn2 +Cn + D. 324 Example Find a closed form for xn = 2xn−1 + 3n−1 . We ﬁnd A = 1. 323 Example Let x0 = 1. The general solution will have the form xn = A3n + Bn2 +Cn + D. We solve the recursion un = 2un−1 as we did on our ﬁrst example: un = 2n u0 = 2n (x0 + 1) = 2n · 8 = 2n+3 . Find a closed form for this recursion. . 322 Example Let x0 = 2. 22 xn−2 2xn−1 xn Adding both columns. We ﬁnd A = B = 1. Find a closed form for this recursion. x2 = 9(25) − 56(2) + 63 = 176. B = 1. The general solution is xn = 3n + n2 . cancelling. x1 = 2(2) + 30 = 5. We obtain 2n x0 2n−1 x1 2n−2 x2 2n−3 x3 . xn = 9xn−1 − 56n + 63. x2 = 3(4) − 2(2)2 + 6(2) − 3 = 13. . . 23 xn−3 + 22 22 xn−2 + 2 2xn−1 + 1 Solution: By raising the subscripts in the homogeneous equation we obtain the characteristic equation xn = 9xn−1 or x = 9. xn = 7 · 2n + (1 + 2 + 22 + · · · + 2n−1 ) = 7 · 2n + 2n − 1 = 2n+3 − 1. We now tackle the case when a = 1. xn = un − 1 = 2n+3 − 1. The general solution will have the form xn = A9n + Bn +C. 4 = 3A + B +C + D. We ﬁnd A = 2.84 Multiply the kth row by 2n−k . . Solution: We test a solution of the form xn = A2n + B3n . Then x0 = 2. Chapter 7 = = = = . 7 = 2A + 3B. xn = 3xn−1 − 2n2 + 6n − 3. 84 . = = = 2n · 7 2n x0 + 2n−1 2n−1 x1 + 2n−2 2n−2 x2 + 2n−3 . x3 = 3(13) − 2(3)2 + 6(3) − 3 = 36. A solution to the homogeneous equation will be of the form xn = A(9)n . B = 7. Solution: By raising the subscripts in the homogeneous equation we obtain the characteristic equation xn = 3xn−1 or x = 9.C = D = 0.C = 0. 176 = 81A + 2B +C. Now x0 = 1. x0 = 2. In this case. Now f (n) = −56n + 63 is a polynomial of degree 1 and so we test a particular solution of the form Bn +C. We solve the system 2 = A + B. 25 = 9A + B +C. we simply consider a polynomial g of degree 1 higher than the degree of f . . A solution to the homogeneous equation will be of the form xn = A(3)n . and adding the geometric sum. The general solution is xn = 2n + 3n . 36 = 27A + 9B + 3C + D. 13 = 9A + 4B + 2C + D.

E = 7. Find a closed formula for xn . Let us now brieﬂy examine how to solve some second order recursions. n n n 7. that is. Therefore. 8 = B +C + E.3 Second Order Recursions All the recursions that we have so far examined are ﬁrst order recursions. Then vn = log un = log un−1 = 2 log un−1 = n . x0 + x1 + x2 + · · · + xn = 7 + x0 + x2 + · · · + xn−1 + (1 + 2 + 3 + · · · + n).Second Order Recursions 325 Example Let x0 = 7 and xn = xn−1 + n. Solution: Observe that am ( j + 1) + 1 = (am ( j))2 + 2am ( j) + 1 = (am ( j) + 1)2 . . Then y j+1 = 2y j . we ﬁnd the next term of the sequence given the preceding one. Then v j+1 = v2 . . . and hence 2n y0 = yn or 2n ln v0 = ln vn or vn = (v0 )2 = (1 + 2d )2 or am (n) + 1 = (1 + 2d )2 . x0 = 7. one more degree than that of f . u2 = un . Cancelling and using the fact that 1 + 2 + · · · + n = n(n + 1) . 10 = 4B + 2C + E. Thus m m n d an (n) = ( 2n + 1)2 − 1 → ed − 1 as n → ∞. x1 = 7 + 1 = 8. Find a closed form for this recursion. Evaluate 327 Example (Putnam 1985) Let d be a real number. am ( j + 1) = (am ( j + 1))2 + 2am ( j). The general solution will have the form xn = A + Bn2 +Cn + D. = 7 x0 + 1 x1 + 2 x2 + 3 . xn Adding both columns. 326 Example A recursion satisﬁes u0 = 3. Now f (n) = n is a polynomial of degree 1 and so we test a particular solution of the form Bn2 +Cn + D. 2 = = = = . n+1 1 Solution: Let vn = log un . and ln v j+1 = 2 ln v j . Since A and D are constants. · · · by am (0) = 2d . So we solve the system 7 = E. 1 n2 n We ﬁnd B = C = . j Put y j = ln v j . x2 = 8 + 2 = 10. As vn = vn−1 /2. The general solution is xn = + + 7. we have vn = v0 /2n . we may combine them to obtain xn = Bn2 +Cn + E. 85 Solution: By raising the subscripts in the homogeneous equation we obtain the characteristic equation xn = xn−1 or x = 1. For each integer m ≥ 0. Now. . . n ≥ 1. j = 0. 2. We now outline a method for solving second order homogeneous linear recurrence relations of the form xn = axn−1 + bxn−2 . log un = (log u0 )/2 n 1/2 vn−1 2 . 2 2 2 Aliter: We have x0 x1 x2 x3 . 85 . xn−1 + n xn = 7 + n(n + 1) . that is. deﬁne a sequence am ( j). 2 Some non-linear ﬁrst order recursions maybe reduced to a linear ﬁrst order recursion by a suitable transformation. n ≥ 1. a constant. A solution to the homogeneous equation will be of the form xn = A(1)n = A. . and m n→∞ lim an (n). j ≥ 0. u = 31/2n . Put v j = am ( j) + 1. 1.

we condition on the last digit. This equation has two roots r1 and r2 . and the number of sequences sought is an−2 . a2 = 3. xn+2 + 5xn+1 + 6xn = 0. Solution: The characteristic equation is f 2 − f − 1 = 0. Thus we test a solution of the form xn = A(−2)n + B(−3)n .6) 330 Example Solve the recursion x0 = 1. whence a solution will have the form √ n √ n 1+ 5 1− 5 fn = A +B . f n = f n−1 + f n−2 . Solution: Let this number be an . a2 = 3. There is a multiple root and so we must test a solution of the form xn = A2n + Bn2n . Solution: The characteristic equation is x2 + 5x + 6 = (x + 3)(x + 2) = 0. we quickly ﬁnd A = 2. the penultimate digit must be 0. 332 Example Let there be drawn n ovals on the plane. This adds 2(n − 1) regions to the an−1 previously existing. i. 4 = 2A + 2B. the nth oval intersects the previous ovals at 2(n − 1) points. Find the characteristic equation by “raising the subscripts” in the form xn = axn−1 + bxn−2 . x1 = −1. 329 Example Find a closed form for the Fibonacci recursion f 0 = 0. Thus an = an−1 + an−2 . 328 Example Let x0 = 1. the number of sequences sought is an−1 . 86 .86 Chapter 7 1. If the roots are identical. B = 1. After the n − 1th stage. Thus an = an−1 + 2(n − 1). a1 = 2. If it is 0. 2 2 The initial conditions give 1+ 5 2 √ 1− 5 2 √ 0 = A + B. Thus the solution is xn = 2(−2)n − (−3)n . f 1 = 1. √ √ 1 5 5 = (A + B) + (A − B) = (A − B) 2 2 2 1=A +B 1 1 This gives A = √ . If an oval intersects each of the other ovals at exactly two points and no three ovals intersect at the same point. the solution will be of the form xn = A(r1 )n + Bn(r1 )n . a1 = 2. 2. Cancelling this gives x2 − ax − b = 0. The solution is thus xn = 2n + n2n . Since 1 = x0 = A + B. To form an . If it is 1. 3. where A. Solution: It is quite easy to see that a1 = 2. 7.e. n ≥ 3. the solution will be of the form xn = A(r1 )n + B(r2 )n . This solves to A = 1. ﬁnd a recurrence relation for the number of regions into which the plane is divided. the nth oval is divided into 2(n − 1) arcs. We thus have the Cauchy-Binet Formula: 5 5 √ n 1 1+ 5 1 −√ fn = √ 2 5 5 √ 1− 5 2 n (7. B = −1. xn = 4xn−1 − 4xn−2 = 0. x1 = 4. If the roots are different. −1 = −2A − 3B.4 Applications of Recursions 331 Example Find the recurrence relation for the number of n digit binary sequences with no pair of consecutive 1’s. Solution: The characteristic equation is x2 − 4x + 4 = (x − 2)2 = 0. B = − √ . The initial conditions give 1 = A. B are constants. Plainly a1 = 2.

· · · . Since n is not going to the r-th position. Hence an = an−1 + n. . the ﬁrst case can happen in (n − 1)Dn−2 ways. 2. (1 ≤ r ≤ n − 1) moves to the n-th position but n moves not to the r-th position. 334 Example (Derangements) An absent-minded secretary is ﬁlling n envelopes with n letters. y1 = y1 − 1 y3 = 5 5 1 x5 = x4 − 6 x4 = 1 . The nth line is cut by he previous n − 1 lines at n − 1 points. On stage three. Solution: Number the envelopes 1. yn . 2 and that at each even stage we have (if Homework 336 Problem Find the sum of all the integers from 1 to 1000 inclusive. r − 1. As r can be chosen in n − 1 ways. Our task is just to misplace the other n − 2 letters. Observe that xn + yn = 1 and that x0 = 1. · · · . 1. 2. · · · . 87 . n = 0. let us say that letter r. y2k = 2k+1 . 3. 337 Problem The sum of a certain number of consecutive positive integers is 1000. y2 = y1 − 1 y1 = 3 3 1 x3 = x2 − 4 x2 = 1 . y1 = y1 − 1 y7 = 9 9 1 2 1 3 1 2 2 5 1 2 3 7 1 2 4 9 1 2 A pattern emerges (which may be proved by induction) that at each odd stage n we have xn = yn = k+1 k 990 n = 2k) x2k = 2k+1 . · · · . the two letters r and n are misplaced. 1/4 of the contains of urn I is passed into urn II. we may relabel n as r. r + 1. You must ﬁnd them all. y1 = y1 + 1 x0 = 2 2 2 1 x2 = x1 + 3 y1 = 2 . Find these integers. Since r can be chosen in n − 1 ways. we can just ignore it. r + 1. 2. adding n new regions to the previously existing an−1 . and this can be done in Dn−1 ways. We condition on the last envelope. the total number of ways for the second case is (n − 1)Dn−1 . Find a recursion for the number Dn of ways in which she never stuffs the right letter into the right envelope. In the second case. one is full of water and the other is empty. On stage four 1/5 of the contains of urn II is passed into urn I. (There is more than one solution. a1 = 2. n.) 338 Problem Use the identity n5 − (n − 1)5 = 5n4 − 10n3 + 10n2 − 5n + 1. · · · . This can be done in Dn−2 ways. 335 Example There are two urns. . Thus Dn = (n − 1)Dn−2 + (n − 1)Dn−1 . In the ﬁrst case. y1 = y1 + 1 x6 = 2 8 1 x8 = x7 + 9 y7 = 5 . On the ﬁrst stage. denote the fraction of water in urns I and II respectively at stage n. (1. We now have n − 1 numbers to misplace. half of the contains of urn I is passed into urn II. 2. y1 = y1 + 1 x4 = 2 6 1 x6 = x5 + 7 y5 = 4 . y1 = y1 + 1 x2 = 2 4 1 x4 = x3 + 5 y3 = 3 . r − 1. which are not multiples of 3 or 5. Two events might happen. y1 = y1 − 1 y5 = 7 7 1 x7 = x6 − 8 x6 = 1 . y0 = 0 x1 = x0 − 1 x0 = 1 . and so on. What fraction of water remains in urn I after the 1978th stage? Solution: Let xn .Homework 87 333 Example Find a recurrence relation for the number of regions into which the plane is divided by n straight lines if every pair of lines intersect. n − 1). Clearly a1 = 2. Either n and r(1 ≤ r ≤ n − 1) trade places or they do not. n − 1) in the slots (1. Since 1978 = 989 we have x1978 = 1979 . Since r has been misplaced. . Solution: Let an be this number. On the second stage 1/3 of the contains of urn II is passed into urn I. but no three lines intersect.

337 Let the the sum of integers be S = (l + 1) + (l + 2) + (l + n). n5 n + 2s3 − 2s2 + s1 − 5 5 n5 n2 (n + 1)2 n(n + 1)(2n + 1) n(n + 1) n + − + − 5 2 3 2 5 5 4 3 n n n n + + − . n = 25. Now 2000 = n opposite parity. 6 n(n + 1) 2 s3 = 13 + 23 + · · · + n3 = . As S = 1000. 338 Using the identity for n = 1 to n: whence s4 = = = 339 Observe that n5 = 5s4 − 10s3 + 10s2 − 5s1 + n. B = 3 + 6 + 9 + · · · + 999 = 3A333 . Since 2000 = 24 53 . The desired sum is D = 15 + 30 + 45 + · · · + 990 = 15A66 . l = 197. Using Gauss’ trick we obtain S = 2 √ 2 + 2ln + n > n2 . Put An = 1 + 2 + 3 + · · · + n. 5 2 3 30 1 1 4 − = . 2 s1 = 1 + 2 + · · · + n = s4 = 14 + 24 + · · · + n4 . l = 27. but put back the multiples of 15. 2 n(n + 1)(2n + 1) s2 = 12 + 22 + · · · + n2 = . 4 · 1 · 3 4 · 999 · 1001 999999 whence the desired sum is 88 . We then see that the problem has the following solutions: n = 1. the odd factors of 2000 are 1. 25. whence n ≤ 2000 = 44. n(2l + n + 1) . 1·3·5 3·5·7 997 · 999 · 1001 Answers 336 We compute the sum of all integers from 1 to 1000 and weed out the sum of the multiples of 3 and the sum of the multiples of 5. l = 999. n and 2l + n + 1 are divisors of 2000 and are of 2000 = n(2l + n + 1).88 and the sums Chapter 7 n(n + 1) . Moreover. n = 5. A1000 − B −C + D = = = A1000 − 3A333 − 5A200 + 15A66 500500 − 3 · 55611 − 5 · 20100 + 15 · 2211 266332. in order to ﬁnd 339 Problem Find the exact value of 1 1 1 + +···+ . 5. n = 16. C = 5 + 10 + 15 + · · · + 1000 = 5A200 . l = 54. 1·3·5 3·5·7 997 · 999 · 1001 1 · 3 999 · 1001 1 1 83333 − = . which we have counted twice. and 125. (2n − 1)(2n + 1) (2n + 1)(2n + 3) (2n − 1)(2n + 1)(2n + 3) Letting n = 1 to n = 499 we deduce that 4 4 4 1 1 + +··· + = − .

If this were allowed we would obtain a multigraph. Figure 8. E) consists of a non-empty set V (called the vertex (node) set) and a set E (possibly empty) of unordered pairs of elements (called the edges or arcs) of V .Chapter 8 Graph Theory 8.6 shews K5 . In these notes we will only consider ﬁnite graphs. which are edges incident to only one vertex.5 shews K4 . ﬁgure 8. Vertices are usually represented by means of dots on the plane. and ﬁgure 8. and we write e = vv . In this case we also say that e is incident with v.4 for some examples of graphs. 2 ¡ Figure 8. and the edges by means of lines connecting these dots. Figure 8. we say that v is adjacent to v and that v and v are neighbours.2: A graph with card (V ) = 2 and card (E) = 1. Figure 8. the graph is ﬁnite or inﬁnite. Depending on whether card (V ) is ﬁnite or not. Neither does it allow loops . 341 Deﬁnition If v and v are vertices of a graph G which are joined by an edge e. ﬁgure 8. See ﬁgures 8.3: A graph with card (V ) = 3 and card (E) = 3.1 Simple Graphs 340 Deﬁnition A simple graph (network) G = (V. 342 Deﬁnition The degree of a vertex is the number of edges incident to it. 343 Deﬁnition The complete graph with n vertices Kn is the graph where any two vertices are adjacent.1 through 8. Thus Kn has n edges.2 shews K2 . We say that vertex v is incident with an edge e if v is an endpoint of e.1: A graph with card (V ) = 1 and card (E) = 0.1 shews K1 . Our deﬁnition of a graph does not allow that two vertices be joined by more than one edge. ﬁgure 8. A graph with loops is a pseudograph.4: A graph with card (V ) = 3 and card (E) = 5. 89 .3 shews K3 . v3 v2 v1 v1 v2 v1 v2 v1 v3 v4 Figure 8.

while a u − v path is a walk that which does not repeat any vertex. and ﬁgure 8.5: K4 . n − 1.n denotes the complete bipartite graph with m + n vertices. E) is a u − v walk that does not repeat an edge. and n vertices v1 · · · vn . E) be a graph.9 shews C5 . and blue.10: Q2 . It is a graph with n edges. 000 Figure 8. . and X and Y are independent sets. A 345 Deﬁnition Km. n − 1. Observe that Qn has n2n−1 edges.3 . E F v3 v4 Figure 8. 350 Deﬁnition Qn denotes the n-dimensional cube. red.8: P3 . .10 shews Q2 .90 Chapter 8 bipartite graph with bipartition X. 347 Deﬁnition A u − v trail in a graph G = (V. 00 10 Figure 8. say. It is a graph with n edges.7 shews K3. 346 Deﬁnition A u − v walk in a graph G = (V. E) is a graph with V1 ⊆ V and E1 ⊆ E. . We will now give a few examples of problems whose solutions become simpler when using a graph-theoretic model.11: Q3 . E1 ) of a graph G = (V. . 348 Deﬁnition Pn denotes a path of length n. v2 v1 C B A B C v2 v1 A D v3 v4 Figure 8. . Vertices of Qn are connected by an edge if and only if they differ by exactly one coordinate. One part. ﬁgure 8. E D Figure 8. and v1 is adjacent to vn . It is a simple graph with 2n vertices.8 shews P3 . 90 . X and Y are called the parts of the bipartition. A D G C D E Figure 8. 352 Example If the points of the plane are coloured with three different colours.6: K5 . ﬁgure 8. with n vertices. 344 Deﬁnition Let G = (V. Figure 8.7: K3. is connected to every other vertex of the other part. where vi is adjacent to vi+1 for n = 1. with m vertices. white. E) is an alternating sequence of vertices and edges in G with starting vertex u and ending vertex v such that every edge joins the vertices immediately preceding it and immediately following it.Y is a graph such that V = X ∪Y . ﬁgure 8. v in S (S may be empty). A subset S ⊆ V is an independent set of vertices if uv ∈ E for all u.12: Example 352. which we label with n-tuples of 0’s and 1’s. 1. and n + 1 vertices v0 v1 · · · vn . . B C A 01 11 010 011 001 111 101 110 B E F 100 Figure 8. 351 Deﬁnition A subgraph G1 = (V1 .9: C5 . X ∩Y = ∅. 349 Deﬁnition Cn denotes a cycle of length n. where vi is adjacent to vi+1 for n = 0.3 . . Figure 8.11 shews Q3 . . shew that there will always exist two points of the same colour which are 1 unit apart.

C). . 91 .15). (iii) takes the lettuce over. . Landau asks the nine people how many hands they shook. 2. Assume the property does not hold and that A is coloured red. .12 all the edges have length 1.Simple Graphs Solution: In ﬁgure 8. or at least three who do not know one another. This means that the ferryman (i) takes the goat across.13. Evidently. 9 must be ruled out. contains a monochromatic triangle (that is. The ferryman wants to take them across. the sequence 1. B is coloured white. then he must have shaken hands with his spouse. 011 000 010 110 001 101 100 111 Figure 8. giving another triangle (see ﬁgure 8. . 0. ¨ ¨ 354 Example (Eotvos Mathematical Competition. (iii) takes the wolf over. . . 0) means that the wolf is on one bank of the river while the goat and the cabbage are on the other bank. You may want to visit http://www. . After the introductions. but his boat is too small to accommodate more than one of them. say red and blue. Another one is 000 → 010 → 110 → 100 → 101 → 111. (ii) returns and that the wolf over bringing back the goat. traversing Q3 while avoiding certain edges. Mr. since if a person shook hands nine times. three of them do not know Peter. This means that the ferryman (i) takes the goat across. (ii) returns and that the lettuce over bringing back the goat. One answer is 000 → 010 → 011 → 001 → 101 → 111. 2. Some people shook hands with some others. Solution: In graph-theoretic terms. as the alternative is argued similarly. D coloured blue. 1. 8. . Each of the nine people asked gives a different number.14. Landau shake? Solution: The given numbers can either be 0. . G. (iii) no one shook hands more than once with the same person. If two of these three people know one another. 1). How many hands did Mrs. The only permissible sequence is thus 0. 9. Let us assume three do know Peter.shtml for a pictorial representation. say (W. (iv) returns and takes the goat over. (1. (iv) returns and takes the goat over. then we have a triangle (Peter and these two. or 1. 0. Consider an arbitrary person of this group (call him Peter). 1. 0) means that the three items are on one bank of the river. . 0. Then F must both be coloured red. a goat. If no two of these three people know one another. he can neither leave the wolf and the goat. The graph depicting both answers can be seen in ﬁgure 8. Since E and C must not be red. . the edges of the triangle have all the same colour). 8. Now.cut-the-knot. and of these. either three of them know Peter or else. that is. For example. then we have three mutual strangers. . The position of the three items can now be given as an ordered triplet. and a cabbage are on one bank of a river. . (0. . . 91 353 Example A wolf. or the cabbage and the goat behind. 2. Landau invite four other married couples for dinner. where the acquaintances are marked by solid lines). 2.13: Example 353. Can the ferryman still get all of them across the river? Solution: Represent the position of a single item by 0 for one bank of the river and 1 for the other bank.org/ctk/GoatCabbageWolf. we also conclude that G is red. (ii) no one shook hands with his spouse. The object of the puzzle is now seen to be to move from (0. 355 Example Mr. There are ﬁve other people. and the following rules were noted: (i) a person did not shake hands with himself. see ﬁgure 8. we need to shew that every colouring of the edges of K6 into two different colours. 0) to (1. 1947) Prove that amongst six people in a room there are at least three who know one another. 1. and Mrs. But then F and G are at distance 1 apart and both coloured red which contradicts our assumption that the property did not hold. which is not allowed. .

21: Theorem 358. since K3 is a graph with this degree sequence. . . The degree sequence 1. (7. so is the sequence n.19: Theorem 358. 6. and in general. 4.22: Theorem 358. A Bi Dj A Cj Bi A Bi D Cj A Bi D Cj Figure 8. the sequence 0. Thus the person that shook hand 7 times is married to the person that shook hands once. . 0). c2 . Figure 8. or with the person that shook 0 hands. This means that he is married to the person who shook 0 hands! We now consider the person that shook 7 hands. 3.18. Landau 0 1 4 3 5 6 7 8 Mr. . Figure 8. · · · . Landau shook hands four times. 357 Example The sequence 1. . meaning that this person’s partner did not give a number. as in ﬁgure 8. But the person that shook hands only once did so with the person shaking 8 hands. since Cn has this sequence. 9 is not. Discounting himself and his spouse. 5. 1). 2. 8. 8 is graphic. Continuing this argument. 2. whereas the sequence ßÞ n twos 1.15: Example 354. n. . 2. since Pn+1 has this sequence. 2 is graphic. Consider the person who shook hands 8 times. (6.14: Example 354. 5. 7. cn . The degree sequence ßÞ n twos 2. This leaves the person that shook hands 4 times without a partner.20: Theorem 358. Landau! Conclusion: Mrs. 2. A graph of the situation appears in ﬁgure 8. From example 355. .2 Graphic Sequences 356 Deﬁnition A sequence of non-negative integers is graphic if there exists a graph whose degree sequence is precisely that sequence. . ßÞ n+1 n s since Kn+1 has this degree sequence. 6 5 4 3 2 7 8 Mr. hence this person must be Mrs. 1 is graphic.16: Example 355.17: Example 355. 4. Landau 0 2 1 2 1 Figure 8. c1 . 92 . n. 3). (5. 1. 358 Theorem (Havel-Hakimi) The two degree sequences I: II : a ≥ b1 ≥ b2 ≥ · · · ≥ ba ≥ c1 ≥ c2 ≥ · · · ≥ cn . . Figure 8. he must have shaken hands with everybody else. ba − 1. . 8. · · · . Figure 8. 2). 1. Figure 8. 1 is graphic. He didn’t shake hands with himself. Figure 8. b2 − 1. Landau 0 4 3 5 6 7 8 Mr. 2. 6. b1 − 1.17. as in ﬁgure 8.18: Example 355. his spouse.16. . 2. .92 Chapter 8 Peter Peter Figure 8. 7. we see the following pairs (8. 3.

362 Deﬁnition A forest is a graph with no cycles (acyclic).3 Connectivity 360 Deﬁnition A graph G = (V. 2. In this case we remove the edges AC j and Bi D and add the edges ABi and DC j to obtain a new graph with the same degree sequence as II. 2 → 4. Bi . E) be a graph. This last sequence is graphic. · · · . 0. 0. 3.20). the original sequence is graphic. 1. 1. 0. Proof: The sum of an odd number of odd numbers is odd. 5. 1. u 359 Example Determine whether the degree sequence 6. 1. but also for multigraphs and pseudographs. v∈V Proof: If the edge connects two distinct vertices. If bi > c j then Bi has at least one more neighbour than C j . As the sequence is arranged in decreasing order. 2. If it happens that bi = c j . Assume now that sequence I is graphic. This ﬁnishes the proof. u 93 . then every vertex having a loop contributes 2 to the sum. 1. By the Havel-Hakimi Theorem. 4. 1. A tree is a connected acyclic graph. 2. and degCi = ci . 3. So assume that there is Bi to which A is not adjacent. Call this neighbour D. 2. 1. 363 Theorem (Handshake Lemma) Let G = (V. 0 → 0. Since the sum of the degrees of the vertices in a simple graph is always even. See ﬁgures 8. 2. 1. 4. 1. we then simply exchange Bi and D j (see ﬁgures 8. If A were adjacent to all the Bi . Proof: Assume ﬁrst that the sequence II is graphic. 2. Then G is a graph whose degree sequence is sequence I. E) is connected if for any two of its vertices there is a path connecting them. 2 is graphic. which is valid not only for simple graphs.4 Traversability We start with the following. 3. 1 → 2. 0. 3. deg Bi = bi . ba − 1. respectively. 1. and so II =⇒ I. and a C j to which A is adjacent. 8. each edge is counted twice. There is a graph G with degree sequence equal to sequence II. 361 Deﬁnition A graph is connected if for any two vertices there is a path with these vertices at its ends. This gives the theorem. 0 → 1. 93 Solution: Using the Havel-Hakimi Theorem successively we have 6. b2 − 1. 1. 2. 8. 1. 2 → 4. 2. 0. A component of a graph is a maximal connected subgraph. one cannot have an odd number of odd degree vertices. We construct the graph G from G by adding a vertex and connecting it to the vertices whose degrees are b1 − 1. u 364 Corollary Every graph has an even number of vertices of odd degree. 2. 5.21 and 8. This process is iterated until A is adjacent to all the Bi .Connectivity are simultaneously graphic.Ci be vertices with deg A = a. as sum traverses through the vertices.22. 1. 1. our task is ﬁnished by simply removing A. Let A. 1 → 2. A spanning tree of a graph of a connected graph G is a subgraph of G which is a tree and having exactly the same of vertices as G. we must have bi ≥ c j .19 and 8. 1. Then deg v = 2card (E) . If the edge is a loop.

Also.94 Chapter 8 365 Deﬁnition A trail is a walk where all the edges are distinct.. vi .. W traverses two of these edges each time it passes through vn and traverses vn−1 vn at the end of the walk. If W were not an Euler tour. vn−1 vn .. 1952) Let G = (V. W must also begin at vn . 94 . u A B D C v1 v2 v2 vi vi+1 vn−1 vn Figure 8. Figure 8. with the seven edges of the graph representing the seven bridges. 368 Deﬁnition A Hamiltonian cycle in a graph is a cycle passing through every vertex. Each time a vertex v is encountered along C. E) be a graph with n = card (E) ≥ 3 edges whose every vertex has degree ≥ n . 366 Theorem A nonempty connected graph is eulerian if and only if has no vertices of odd degree. that is. there is a Hamiltonian path v1 v2 . that is. since C begins and ends in u. Call this edge uvi .. vn−1 vn . Figure 8. Unlike Theorem 366. An Eulerian trail on a graph G is a trail that traverses every edge of G.. d(u) must also be even. The townsfolk used to amuse themselves by crossing over the bridges and asked whether it was possible to ﬁnd a trail starting and ending in the same location allowing one to traverse each of the bridges exactly once. two of the edges incident to v are accounted for. Let W be the longest walk in G that traverses every edge at most once: W = v0 . Then G cannot be complete. there is no simple characterisation of all graphs with a Hamiltonian cycle. assume that G is a connected noneulerian graph with at least one edge and no vertices of odd degree. But then we can construct a longer walk: u. Let a and b be two non-adjacent vertices of G. vn . By Theorem 366. G is Hamiltonian if it contains a Hamiltonian cycle. W could be extended into a longer walk. ¨ 367 Example (Konigsberg Bridge Problem) The town of K¨ nigsberg (now called Kaliningrad) was built on an island in the Pregel River. G + ab is Hamiltonian. Hence. v1 . 369 Theorem (Dirac’s Theorem. and that G has more than 3 vertices. o The island sat near where two branches of the river join. and each of its Hamiltonian cycles must contain the edge ab. vn−1 . v0 v1 . v2 . we could ﬁnd an edge not in W but incident to some vertex in W since G is connected. so W must be an Euler tour. Conversely. This contradicts the deﬁnition of W . however. In particular.24: Theorem 369 The following problem is perhaps the originator of graph theory. vi−1 vi . Put S = {vi : avi+1 ∈ E} and {v j : v j b ∈ E}.23: Example 367.. and let C be an Euler tour of C starting and ending at vertex u. Since C contains every edge of G. v0 v1 . seven bridges had been erected. and the borders of the town spreaded over to the banks of the river as well as a nearby promontory. This accounts for an odd number of edges.. . By deﬁnition of G. A graph is eulerian if it contains an Euler tour. d(v) is then even for all v = u. Proof: Assume ﬁrst that G is eulerian. Then 2 G is Hamiltonian. . uvi . .. suppose G is a maximal non-Hamiltonian with with n ≥ 3. vn in G beginning at v1 = a and ending at vn = b. a closed Euler trail. Between these four land masses. Hence. v1 v2 . this graph is not Eulerian so it is impossible to ﬁnd a trail as the townsfolk asked. vi . Proof: Arguing by contradiction. . otherwise.23 has a graph theoretic model of the town. vi vi+1 . but the degree of vn is even by assumption. . v0 = vn . vn . An Euler tour on G is a tour traversing each edge of G exactly once. We have the following one way result. Then W must traverse every edge incident to vn .. A tour of G is a closed walk that traverses each edge of G at least once.

Therefore. we have arrived at a contradiction. So v − e + f = 2 by the induction assumption P(e). u 2 2 95 8. G is connected since there is a path between every pair of vertices within the spanning tree. but not in the tree.Planarity As vn ∈ S ∩ T we must have card (S ∪ T ) = n. K4 has 4 faces. establishing P(e + 1). since if vi § ∩ T then G would have the Hamiltonian cycle v1 v2 · · · vi vn vn−1 · · · vi+1 v1 . we must have v = e + 2. v vertices. Then there is only the outside face. But then v − e + f = 2 =⇒ (v) − (e + 1) + ( f + 1) = 2 =⇒ v − e + f = 2. v − e + f = 1 − 0 + 1 = 2. This ﬁnishes the proof. as shewn in ﬁgure 8.25. Since there are e + 1 edges and G is connected. 373 Example From ﬁgure 8. S ∩ T = ∅. e edges. and consider a connected graph G with e + 1 edges. or G has at least one cycle.25.5 Planarity 370 Deﬁnition A graph is planar if it can be drawn in a plane with no intersecting edges. Either G has no cycles. Such an edge is guaranteed by the fact that a tree has no cycles.25: Example 373.24. and f faces. contrary to the assumption that G is non-Hamiltonian. is called the outside face. 374 Theorem (Euler’s Formula) For every drawing of a connected planar graph with v vertices. This gives (e + 2) − (e + 1) + 1 = 2 − 1 + 1 = 2. Proof: The proof is by induction on e. establishing P(e + 1). 371 Example K4 is planar. then we must have v = 1 and hence f = 1. since there is only the outside face. But since we are assuming that d(a) ≥ n n and d(b) ≥ . establishing P(0). and so f = 1. Moreover. as in ﬁgure 8. But then d(a) + d(b) = card (S) + card (T ) = card (S ∪ T ) + card (S ∩ T ) < n. Consider a spanning tree of G and an edge uv in the cycle. Let P(e) be the proposition that v − e + f = 2 for every drawing of a graph G with e edges. and f faces the following formula holds: v − e + f = 2. Assume now P(e) is true. If e = 0 and it is connected. 372 Deﬁnition A face of a planar graph is a region bounded by the edges of the graph. A 3 B 2 4 D C 1 Figure 8. Face 1 which extends indeﬁnitely. u 95 . Deleting uv merges the two faces on either side of the edge and leaves a graph G with only e edges.

we obtain a planar graph.3 has 3 · 3 = 9 edges and 9 > 8 = 2(6) − 4. ¡ 379 Deﬁnition A Platonic solid is a polyhedron having congruent regular polygon as faces and having the same number of edges meeting at each corner. in the corresponding planar graph. By puncturing a face of a polyhedron and spreading its surface into the plane. Since G is simple. Moreover. for 1 ≤ k ≤ f . This gives 2e ≥ 4 f and by Euler’s Formula. three-dimensional region bounded by a ﬁnite number of polygonal faces. We then have F1 + F2 · · · + F f ≥ 3 f . we deduce that 2e ≥ 3 f . let Fk denote the number of edges on the k-th face. every edge lies in the boundary of at most two faces. Every simple planar graph with v ≥ 3 vertices and which does not have a C3 has e ≤ 2v − 4 edges. It follows from Euler’s Formula that 2e 2e 1 1 1 1 −e+ = 2 =⇒ + = + . If there are f faces. The table below gives the existing polyhedra. m n m n e 2 We must have n ≥ 3 and m ≥ 3 for a nondegenerate polygon. Hence if E j denotes the number of faces that the j-th edge has. then. if either n or m were ≥ 6 then ≤ 1 1 1 1 1 + = < + . there are m edges incident to each of the v vertices. every face has at least 3 edges in its boundary. By Euler’s Formula we then have e ≤ 3v − 6. Also. we have mv = 2e. 3 6 2 e 2 Thus we only need to check the ﬁnitely many cases with 3 ≤ n. e ≤ 2v − 4. u 376 Example K5 is not planar by Theorem 375 since K5 has 5 = 10 edges and 10 > 9 = 3(5) − 6. The second statement follows for v = 4 by inspecting all graphs G with v = 4. We may also assume that G is connected. 380 Example (Platonic Solid Problem) How many Platonic solids are there? If m is the number of faces that meet at each corner of a polyhedron. Proof: If v = 3.3 is not planar by Theorem 375 since K3. Assume then that v ≥ 5 and that G has no cycle of length 3. otherwise. 2 377 Example K3. As each edge is incident to two vertices. both statements are plainly true so assume that G is a maximal planar graph with v ≥ 4. 96 . 378 Deﬁnition A polyhedron is a convex. and n is the number of sides on each face.96 Chapter 8 375 Theorem Every simple planar graph with v ≥ 3 vertices has at e ≤ 3v − 6 edges. then 2e ≥ E1 + E2 + · · · + Ee . Since E1 + E2 + · · · + Ee = F1 + F2 · · · + F f . we may add an edge to G. n 3 4 3 3 5 m 3 3 4 5 3 v 4 8 6 12 20 e 6 12 12 30 30 f 4 6 8 20 12 polyhedron tetrahedron cube octahedron icosahedron dodecahedron ¡ ¡ 381 Example (Regions in a Circle) Prove that the chords determined by n points on a circle cut the interior into 1 + n + n regions 2 4 provided no three chords have a common intersection. and if each face is bounded by n edges. Then each face has at least four edges on its boundary. we also have n f = 2e. m ≤ 5.

They decide that each will send a postcard to three of the others. By the Pigeonhole Principle. say Charlie. 3. say Eric. 4. these three people only correspond with one another on topic III. and we are done. that the sequence n. 2. Otherwise. 5. Each intersection of the ¡ chords is determined by four points on the circle. Charlie must write to at least six of the people of one topic. 1 → 5. 385 Problem If a given convex polyhedron has six vertices and twelve edges. 4. 2. 3. then Eric and this pair correspond on topic II. every face must have exactly three edges. 386 Problem Prove. 4. 2. 1. 0 → 1. 2. 2. 384 Choose a particular person of the group. 2. n n2 n + + − 4 2 2 n n n +n = 1+ + 4 2 4 1 n 4 + n(n + 1) 2 4 Homework 382 Problem Determine whether there is a simple graph with eight vertices having degree sequence 6. 1. 4. 4. say topic I. 0 → 3. n − 1.Homework 97 Solution: By viewing the points on the circle and the intersection of two chords as vertices. 0 → This last sequence is graphic. 5. 1. we have 7. 2. Hence x = than three edges. Hence the original sequence is graphic. Then we must have x f = 2e. we obtain a plane graph. 4. Each pair of correspondents deals with only one of these topics. 5. 1 is graphic. . Prove that there at least three people who write to each other about the same topic. . 1 is always graphic. If amongst these three there is a pair that corresponds with each other on topic II. 2e 24 = = 3. 3. using induction. there must be three of the ﬁve remaining that correspond with Eric in one of the topics. 3. 385 Let x be the average number of edges per face. 4. these six correspond amongst themselves only on topics II or III. 0. 1. Since each vertex inside the circle has degree 4 4 and each vertex on the circumference of the circle has degree n + 1. Discounting the outside face. Is it possible that every student receives postcards from precisely the three to whom he sent postcards? Prove your answer! Answers 383 Using the Havel-Hakimi Theorem. Since no face can have fewer f 8 97 . prove that every face is a triangle. 3. He corresponds with sixteen others. 6. 2. 3. In their letters only three different topics are discussed. and we are done again. 0. . If any pair of these six people corresponds on topic I. Choose a particular person from this group of six. 2. By the Pigeonhole Principle. and we are done. and hence our graph has v = n + n vertices. Otherwise. then Charlie and this pair do the trick. . our graph has f −1 = 1+e−v = 1+2 faces or regions. 387 Problem Seven friends go on holidays. say topic II. 4. the Handshake Lemma (Theorem 363) we have a total of e= edges. 2. 2. 3. 383 Problem Determine whether the sequence 7. n. n − 1. 6. 384 Problem (IMO 1964) Seventeen people correspond by mail with one another—each one with all the rest.

. one of degree of n − 2. u. 2.. n − 1. one vertex of degree 1. 387 The sequence 3. Join v to one vertex of degree n − 1. n. . v. 3. 1.98 386 The sequence 1. 98 . 2. 3. 4. Finally. 3. 0. . 1. 3. n − 2. 3. n − 2. n − 1. 1. 4. . n − 1. . n − 1. Since v is joined to n − 1 vertices. 1 Chapter 8 is graphic and add two vertices. 4. Thus the given condition is not realisable. . join u to v to obtain the sequence n. 3. 3. 3. n − 1. 3. 3. 3. we have a sequence n. . as the number of vertices of odd degree is odd. .. etc. 4. . Assume that the sequence n − 1. n − 1. and u so far is not joined to any vertex. . 3 is not graphic. . 2. 2. 2. 1 is clearly graphic. 2. 1. 4. . 4.

- wolstenholmeUploaded byยุงบินชุก อยู่บนยอดดอย
- MTAP Reviewer Grade 3Uploaded byClarisa Ella
- jhtp4_02Uploaded byapi-3714422
- Primes and Divisors 2Uploaded byMark
- Java Operator PrecedenceUploaded byVenu Kongara
- AbstractUploaded byscience2010
- Rules of InferenceUploaded byRay Mejias
- Haoudout1-4Uploaded byYousefHammid
- Grade 8 Skill SheetsUploaded byVincents Genesius Evans
- A Note on the Smarandache Near-To-Primorial FunctionUploaded byMia Amalia
- SurveyofGreen-TaoTheoremUploaded byjohnwmith3
- Goldbach's Strong ConjectureUploaded byMeraj Alam
- Infix2PostfixUploaded byKireeti Gupta
- Stellarium User Guide 0.18.2 1Uploaded byLuis Enrique
- course syllabusUploaded byapi-250789865
- Number SystemsUploaded byJyoti Sukhija
- ReadmeUploaded byLuiz Carlos
- 6th grade math practice 2Uploaded byapi-248877347
- Understanding Core Programming part2Uploaded byCristy Balubayan Nazareno
- EMMANUEL HIGH SCHOOL MATH.docxUploaded byMichael Hernandez
- Diophantine EquationsUploaded byryszard_lubicz
- user-manual.pdfUploaded byOscar Osil
- XTM 5 Series HardwareGuideUploaded byLuis Perez Gonzalez
- Remainder theorem.docxUploaded byShivam Shukla
- French 2013Uploaded byAmanda von Richten
- Prelim2015 SolUploaded by游祥輝
- c QuestionsUploaded bySalini Rajan
- The Natural NumbersUploaded byStephen Bankes
- maths 0580 2014Uploaded bySuresh
- ch03Uploaded byAbhiram Shaji

- Discrete Mathematics 2005Uploaded byblack2lamin
- Discrete Mathematics 2005Uploaded byblack2lamin
- 14102008 Jitmm a15 Ramasoota TuberculosisUploaded byblack2lamin
- Full ExampleUploaded byblack2lamin
- Multi Algoerithm Kruppa-slidesUploaded byblack2lamin
- What is the Difference Between L1 Cache and L2 CacheUploaded byblack2lamin