list of symbols · list of symbols symbol meaning page z ... 2.3 operations in nondecimal bases ......

801

Upload: dangnhu

Post on 19-Apr-2018

240 views

Category:

Documents


6 download

TRANSCRIPT

  • List of Symbols

    Symbol Meaning PageZ set of integers (3)x S x belongs to set S (3)x / S x does not belong to set S (3)Z+ set of positive integers (3)N set of positive integers (3)W set of whole numbers (4)a < b a is less than b (4)a > b a is greater than b (4)a b a < b or a = b (5)a b a > b or a = b (5)min{x, y} the minimum of x and y (5)max{x, y} the maximum of x and y (5)|x| the absolute value of x (5)x the floor of the real number x (6)x the ceiling of the real number x (6)i=mi=k

    ai =m

    i=kai =

    m

    kai ak + ak+1 + + am (9)

    iIai the sum of the values of ai as i runs over the various values in I (11)

    Paij the sum of the values of aij, where i and j satisfy properties P (11)

    i=mi=k

    ai =m

    i=kai =

    m

    kai akak+1 am (13)

    n! n factorial (13)(n

    r

    )

    binomial coefficient (33)

    tn triangular number (40)sn square number (44)pn pentagonal number (46)hn hexagonal number (48)Tn tetrahedral number (49)Sn square pyramidal number (50)Pn pentagonal pyramidal number (51)Hn hexagonal pyramidal number (51)a div b the quotient when a is divided by b (71)a mod b the remainder when a is divided by b (71)

    Symbol Meaning Pagea|b a is a factor of b (74)a b a is not a factor of b (74)|A| the number of elements in set A (76)A B the union of sets A and B (76)A B the intersection of sets A and B (76)A the complement of set A (76)N = (akak1 . . .a1a0)b base-b representation of N (83)Rn repunit with n ones (96)(x) the number of primes x (110)Fn the nth Fibonacci number (129)Ln the nth Lucas number (136)|A| the determinant of matrix A (138)fn the nth Fermat number (139)(a,b) the greatest common factor of a and b (155)(a1,a2, . . . ,an) the greatest common factor of a1,a2, . . . , and an (162)pa n pa exactly divides n (183)[a,b] the least common multiple of a and b (184)[a1,a2, . . . ,an] the least common multiple of a1,a2, . . . , and an (187)a b (mod m) a is congruent to b modulo m (212)a b (mod m) a is not congruent to b modulo m (212)[r] the congruence class represented by r (216)a1 an inverse of a modulo m (234)(n) the digital root of n (291)In the identity matrix of order n (316)n# the product of primes n (325)(n) Eulers phi function (342)(n) the number of positive factors of n (365)(n) the sum of the positive factors of n (366)Mp Mersenne number 2p 1 (381)(n) Mbius function (398)(n) Liouville function (405)ordm a the order of a modulo m (456)(d) the number of incongruent residues of order d modulo p (470)ind a the index of a to the base (483)(a/p) Legendre symbol (501)(a/m) Jacobi symbol (527)(a/n) Kronecker symbol (549)

  • Elementary Number Theory withApplications

    Second Edition

  • Elementary Number Theory withApplications

    Second Edition

    Thomas Koshy

    AMSTERDAM BOSTON HEIDELBERG LONDONNEW YORK OXFORD PARIS SAN DIEGO

    SAN FRANCISCO SINGAPORE SYDNEY TOKYO

    Academic Press is an imprint of Elsevier

  • Academic Press is an imprint of Elsevier30 Corporate Drive, Suite 400, Burlington, MA 01803, USA525 B Street, Suite 1900, San Diego, California 92101-4495, USA84 Theobalds Road, London WC1X 8RR, UK

    This book is printed on acid-free paper.

    Copyright 2007, Elsevier Inc. All rights reserved.

    No part of this publication may be reproduced or transmitted in any form or by any means, electronicor mechanical, including photocopy, recording, or any information storage and retrieval system, withoutpermission in writing from the publisher.

    Permissions may be sought directly from Elseviers Science & Technology Rights Department in Oxford,UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, E-mail: [email protected]. You mayalso complete your request on-line via the Elsevier homepage (http://elsevier.com), by selecting Support& Contact then Copyright and Permission and then Obtaining Permissions.

    Library of Congress Cataloging-in-Publication Data

    Koshy, Thomas.Elementary number theory with applications / Thomas Koshy. 2nd ed.

    p. cm.Includes bibliographical references and index.ISBN 978-0-12-372487-8 (alk. paper)1. Number theory. I. Title.

    QA241.K67 2007512.7dc22

    2007010165

    British Library Cataloguing-in-Publication DataA catalogue record for this book is available from the British Library.

    ISBN: 978-0-12-372487-8

    For information on all Academic Press publicationsvisit our Web site at www.books.elsevier.com

    Printed in the United States of America07 08 09 10 9 8 7 6 5 4 3 2 1

  • Dedicated tomy sister, Aleyamma Zachariah, and my brother,M. K. Tharian; and to the memory ofProfessor Edwin Weiss, Professor Donald W. Blackett,and Vice Chancellor A. V. Varughese

  • Contents

    Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

    A Word to the Student . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi

    1 Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 Fundamental Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 The Summation and Product Notations . . . . . . . . . . . . . . . . . . . . . 91.3 Mathematical Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.4 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261.5 The Binomial Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321.6 Polygonal Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391.7 Pyramidal Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491.8 Catalan Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

    2 Divisibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692.1 The Division Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    2.2 Base-b Representations (optional) . . . . . . . . . . . . . . . . . . . . . . . . . 802.3 Operations in Nondecimal Bases (optional) . . . . . . . . . . . . . . . . . . . 892.4 Number Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 982.5 Prime and Composite Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 1032.6 Fibonacci and Lucas Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 1282.7 Fermat Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    vii

  • viii Contents

    3 Greatest Common Divisors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1553.1 Greatest Common Divisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1553.2 The Euclidean Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1663.3 The Fundamental Theorem of Arithmetic . . . . . . . . . . . . . . . . . . . . 1733.4 Least Common Multiple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1843.5 Linear Diophantine Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

    4 Congruences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2114.1 Congruences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2114.2 Linear Congruences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2304.3 The Pollard Rho Factoring Method . . . . . . . . . . . . . . . . . . . . . . . . . 238Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

    5 Congruence Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2475.1 Divisibility Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2475.2 Modular Designs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2535.3 Check Digits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    5.4 The p-Queens Puzzle (optional) . . . . . . . . . . . . . . . . . . . . . . . . . . 2735.5 Round-Robin Tournaments (optional) . . . . . . . . . . . . . . . . . . . . . . . 2775.6 The Perpetual Calendar (optional) . . . . . . . . . . . . . . . . . . . . . . . . . 282Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    6 Systems of Linear Congruences . . . . . . . . . . . . . . . . . . . . . . . . 2956.1 The Chinese Remainder Theorem . . . . . . . . . . . . . . . . . . . . . . . . . 295

    6.2 General Linear Systems (optional) . . . . . . . . . . . . . . . . . . . . . . . . . 303

  • Contents ix

    6.3 2 2 Linear Systems (optional) . . . . . . . . . . . . . . . . . . . . . . . . . . 307Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

    7 Three Classical Milestones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3217.1 Wilsons Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3217.2 Fermats Little Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

    7.3 Pseudoprimes (optional) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3377.4 Eulers Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

    8 Multiplicative Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3558.1 Eulers Phi Function Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3558.2 The Tau and Sigma Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3658.3 Perfect Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3738.4 Mersenne Primes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

    8.5 The Mbius Function (optional) . . . . . . . . . . . . . . . . . . . . . . . . . . . 398Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

    9 Cryptology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4139.1 Affine Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4169.2 Hill Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4259.3 Exponentiation Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4309.4 The RSA Cryptosystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4349.5 Knapsack Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

  • x Contents

    Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

    10 Primitive Roots and Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45510.1 The Order of a Positive Integer . . . . . . . . . . . . . . . . . . . . . . . . . . 45510.2 Primality Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46410.3 Primitive Roots for Primes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467

    10.4 Composites with Primitive Roots (optional) . . . . . . . . . . . . . . . . . . 47410.5 The Algebra of Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493

    11 Quadratic Congruences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49511.1 Quadratic Residues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49511.2 The Legendre Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50111.3 Quadratic Reciprocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51511.4 The Jacobi Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527

    11.5 Quadratic Congruences with Composite Moduli (optional) . . . . . . . . 535Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550

    12 Continued Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55112.1 Finite Continued Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55212.2 Infinite Continued Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578

    13 Miscellaneous Nonlinear Diophantine Equations . . . . . . . . . . 57913.1 Pythagorean Triangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579

  • Contents xi

    13.2 Fermats Last Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59013.3 Sums of Squares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60213.4 Pells Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621Review Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623Supplementary Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626Computer Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628Enrichment Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628

    A Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631A.1 Proof Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631A.2 Web Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638

    T Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641T.1 Factor Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642T.2 Values of Some Arithmetic Functions . . . . . . . . . . . . . . . . . . . . . . . 649T.3 Least Primitive Roots r Modulo Primes p . . . . . . . . . . . . . . . . . . . . . 652T.4 Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653

    R References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657

    S Solutions to Odd-Numbered Exercises . . . . . . . . . . . . . . . . . . . 665Chapter 1 Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665

    Chapter 2 Divisibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677

    Chapter 3 Greatest Common Divisors . . . . . . . . . . . . . . . . . . . . . . . . . . . 689

    Chapter 4 Congruences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696

    Chapter 5 Congruence Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702

    Chapter 6 Systems of Linear Congruences . . . . . . . . . . . . . . . . . . . . . . . 707

    Chapter 7 Three Classical Milestones . . . . . . . . . . . . . . . . . . . . . . . . . . . 711

    Chapter 8 Multiplicative Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718

    Chapter 9 Cryptology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728

    Chapter 10 Primitive Roots and Indices . . . . . . . . . . . . . . . . . . . . . . . . . . 731

    Chapter 11 Quadratic Congruences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737

    Chapter 12 Continued Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746

    Chapter 13 Miscellaneous Nonlinear Diophantine Equations . . . . . . . . . . . . 748

    Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 761

  • Preface

    Man has the faculty of becoming completely absorbed in one subject,

    no matter how trivial and no subject is so trivial that it will not assume

    infinite proportions if ones entire attention is devoted to it.

    TOLSTOY, War and Peace

    or over two thousand years, number theory has fascinated and inspired bothF amateurs and mathematicians alike. A sound and fundamental body of knowl-edge, it has been developed by the untiring pursuits of mathematicians allover the world. Today, number theorists continue to develop some of the most so-phisticated mathematical tools ever devised and advance the frontiers of knowl-edge.

    Many number theorists, including the eminent nineteenth-century English num-ber theorist Godfrey H. Hardy, once believed that number theory, although beautiful,had no practical relevance. However, the advent of modern technology has broughta new dimension to the power of number theory: constant practical use. Once con-sidered the purest of pure mathematics, it is used increasingly in the rapid develop-ment of technology in a number of areas, such as art, coding theory, cryptology, andcomputer science. The various fascinating applications have confirmed that humaningenuity and creativity are boundless, although many years of hard work may beneeded to produce more meaningful and delightful applications.

    The Pursuit of a Dream

    This book is the fruit of years of dreams and the authors fascination for the subject,its beauty, elegance, and historical development; the opportunities it provides forboth experimentation and exploration; and, of course, its marvelous applications.

    This new edition, building on the strengths of its predecessor, incorporates anumber of constructive suggestions made by students, reviewers, and well-wishers. Itis logically conceived, self-contained, well-organized, nonintimidating, and writtenwith students and amateurs in mind. In clear, readable language, this book offers anoverview of the historical development of the field, including major figures, as well

    xiii

  • xiv Preface

    as step-by-step development of the basic concepts and properties, leading to the moreadvanced exercises and discoveries.

    Audience and Prerequisites

    The book is designed for an undergraduate course in number theory for studentsmajoring in mathematics and/or computer science at the sophomore/junior level andfor students minoring in mathematics. No formal prerequisites are required to studythe material or to enjoy its beauty except a strong background in college algebra.The main prerequisite is mathematical maturity: lots of patience, logical thinking,and the ability for symbolic manipulation. This book should enable students andnumber theory enthusiasts to enjoy the material with great ease.

    Coverage

    The text includes a detailed discussion of the traditional topics in an undergradu-ate number theory course, emphasizing problem-solving techniques, applications,pattern recognition, conjecturing, recursion, proof techniques, and numeric compu-tations. It also covers figurate numbers and their geometric representations, Catalannumbers, Fibonacci and Lucas numbers, Fermat numbers, an up-to-date discussionof the various classes of prime numbers, and factoring techniques. Starred () op-tional sections and optional puzzles can be omitted without losing continuity of de-velopment.

    Included in this edition are new sections on Catalan numbers and the Pollardrho factoring method, a subsection on the Pollard p 1 factoring method, and ashort chapter on continued fractions. The section on linear diophantine equationsnow appears in Chapter 3 to provide full prominence to congruences.

    A number of well-known conjectures have been added to challenge the more am-bitious students. Identified by the conjecture symbol ? in the margin, they shouldprovide wonderful opportunities for group discussion, experimentation, and explo-ration.

    Examples and Exercises

    Each section contains a wealth of carefully prepared and well-graded examples andexercises to enhance student skills. Examples are developed in detail for easy un-derstanding. Many exercise sets contain thought-provoking true/false problems, nu-meric problems to develop computational skills, and proofs to master facts and thevarious proof techniques. Extensive chapter-end review exercise sets provide com-prehensive reviews, while chapter-end supplementary exercises provide challengingopportunities for the curious-minded to pursue.

  • Preface xv

    Starred () exercises are, in general, difficult, and doubly starred () ones aremore difficult. Both can be omitted without losing overall understanding of the con-cepts under discussion. Exercises identified with a c in the margin require a knowl-edge of elementary calculus; they can be omitted by students with no calculus back-ground.

    Historical Comments and Biographies

    Historical information, including biographical sketches of about 50 mathematicians,is woven throughout the text to enhance a historical perspective on the develop-ment of number theory. This historical dimension provides a meaningful context forprospective and in-service high school and middle school teachers in mathematics.An index of the biographies, keyed to pages in the text, can be found inside the backcover.

    Applications

    This book has several unique features. They include the numerous relevant andthought-provoking applications spread throughout, establishing a strong and mean-ingful bridge with geometry and computer science. These applications increase stu-dent interest and understanding and generate student interaction. In addition, thebook shows how modular systems can be used to create beautiful designs, link-ing number theory with both geometry and art. The book also deals with barcodes,zip codes, International Serial Book Numbers, European Article Numbers, vehicleidentification numbers, and German bank notes, emphasizing the closeness of num-ber theory to our everyday life. Furthermore, it features Friday-the-thirteenth, thep-queens puzzle, round-robin tournaments, a perpetual calendar, the Pollard rho fac-toring method, and the Pollard p 1 factoring method.

    Flexibility

    The order and selection of topics offer maximum flexibility for instructors to selectchapters and sections that are appropriate for student needs and course lengths. Forexample, Chapter 1 can be omitted or assigned as optional reading, as can the op-tional sections 6.2, 6.3, 7.3, 8.5, 10.4, and 11.5, without jeopardizing the core ofdevelopment. Sections 2.2, 2.3, and 5.45.6 also can be omitted if necessary.

    Foundations

    All proof methods are explained and illustrated in detail in the Appendix. They pro-vide a strong foundation in problem-solving techniques, algorithmic approach, andproof techniques.

  • xvi Preface

    Proofs

    Most concepts, definitions, and theorems are illustrated through thoughtfully selectedexamples. Most of the theorems are proven, with the exception of some simple onesleft as routine exercises. The proofs shed additional light on the understanding of thetopic and enable students to develop their problem-solving skills. The various prooftechniques are illustrated throughout the text.

    Proofs Without Words

    Several geometric proofs of formulas are presented without explanation. This uniquefeature should generate class discussion and provide opportunities for further explo-ration.

    Pattern Recognition

    An important problem-solving technique used by mathematicians is pattern recogni-tion. Throughout the book, there are ample opportunities for experimentation and ex-ploration: collecting data, arranging them systematically, recognizing patterns, mak-ing conjectures, and then establishing or disproving these conjectures.

    Recursion

    By drawing on well-selected examples, the text explains in detail this powerful strat-egy, which is used heavily in both mathematics and computer science. Many exam-ples are provided to ensure that students are comfortable with this powerful problem-solving technique.

    Numeric Puzzles

    Several fascinating, optional number-theoretic puzzles are presented for discussionand digression. It would be a good exercise to justify each. These puzzles are usefulfor prospective and in-service high school and middle school teachers in mathemat-ics.

    Algorithms

    A number of algorithms are given as a problem-solving technique in a straightfor-ward fashion. They can easily be translated into computer programs in a languageof your choice. These algorithms are good candidates for class discussion and areboxed in for easy identification.

  • Preface xvii

    Computer Assignments

    Relevant and thought-provoking computer assignments are provided at the end ofeach chapter. They provide hands-on experience with concepts and enhance the op-portunity for computational exploration and experimentation. A computer algebrasystem, such as Maple or Mathematica, or a language of your choice can be used.

    Chapter Summary

    At the end of each chapter, you will find a summary that is keyed to pages in the text.This provides a quick review and easy reference. Summaries contain the variousdefinitions, symbols, and properties.

    Enrichment Readings

    Each chapter ends with a carefully prepared list of readings from various sources forfurther exploration of the topics and for additional enrichment.

    Web Links

    Relevant annotated web sites are listed in the Appendix. For instance, up-to-dateinformation on the discovery of Mersenne primes and twin primes is available onthe Internet. This enables both amateurs and professionals to access the most recentdiscoveries and research.

    Special Symbols

    The square denotes the end of a proof and an example. The conjecture symbol ?indicates an unresolved problem.

    Index of Symbols

    Inside the front cover, you will find, for quick reference, a list of symbols and thepage numbers on which they first occur.

    Odd-Numbered Solutions

    The solutions to all odd-numbered exercises are given at the end of the text.

    Solutions Manual for Students

    The Students Solutions Manual contains detailed solutions to all even-numbered ex-ercises. It also contains valuable tips for studying mathematics, as well as for prepar-ing and taking examinations.

  • xviii Preface

    Instructors Manual

    The Instructors Manual contains detailed solutions to all even-numbered exercises,sample tests for each chapter, and the keys for each test. It also contains two samplefinal examinations and their keys.

    Highlights of this Edition

    They include:

    Catalan numbers (Sections 1.8, 2.5, and 8.4) Linear diophantine equations with Fibonacci coefficients (Section 3.5) Pollard rho factoring method (Section 4.3) Vehicle identification numbers (Section 5.3) German bank notes (Section 5.3) Factors of 2n + 1 (Section 7.2) Pollard p 1 factoring method (Section 7.2) Pascals binary triangle and even perfect numbers (Section 8.4) Continued fractions (Chapter 12) Well-known conjectures Expanded exercise sets

    Acknowledgments

    I am grateful to a number of people for their cooperation, support, encouragement,and thoughtful comments during the writing and revising of this book. They all haveplayed a significant role in improving its quality.

    To begin with, I am indebted to the following reviewers for their boundless en-thusiasm and constructive suggestions:

    Steven M. Bairos Data Translation, Inc.Peter Brooksbank Bucknell UniversityRoger Cooke University of VermontJoyce Cutler Framingham State CollegeDaniel Drucker Wayne State UniversityMaureen Femick Minnesota State University at MankatoBurton Fein Oregon State UniversityJustin Wyss-Gallifent University of MarylandNapolean Gauthier The Royal Military College of CanadaRichard H. Hudson University of South CarolinaRobert Jajcay Indiana State UniversityRoger W. Leezer California State University at Sacramento

  • Preface xix

    I. E. Leonard University of AlbertaDon Redmond Southern Illinois UniversityDan Reich Temple UniversityHelen Salzberg Rhode Island CollegeSeung H. Son University of Colorado at Colorado SpringsDavid Stone Georgia Southern UniversityM. N. S. Swamy Concordia UniversityFernando Rodriguez Villegas University of Texas at AustinBetsey Whitman Framingham State CollegeRaymond E. Whitney Lock Haven University

    Thanks also to Roger Cooke of the University of Vermont, Daniel Drucker of WayneState University, Maureen Fenrick of Minnesota State University at Mankato, andKevin Jackson-Mead for combing through the entire manuscript for accuracy; toDaniel Drucker of Wayne State University and Dan Reich of Temple University forclass-testing the material; to the students Prasanth Kalakota of Indiana State Uni-versity and Elvis Gonzalez of Temple University for their comments; to Thomas E.Moore of Bridgewater State College and Don Redmond of Southern Illinois Uni-versity for preparing the solutions to all odd-numbered exercises; to Ward Heilmanof Bridgewater State College and Roger Leezer of California State University atSacramento for preparing the solutions to all even-numbered exercises; to MargariteRoumas for her superb editorial assistance; and to Madelyn Good and Ellen Keane atthe Framingham State College Library, who tracked down a number of articles andbooks. My sincere appreciation also goes to Senior Editors Barbara Holland, whoinitiated the original project, Pamela Chester, and Thomas Singer; Production EditorChristie Jozwiak, Project Manager Jamey Stegmaier, Copyeditor Rachel Henriquez,and Editorial Assistant Karen Frost at Harcourt/Academic Press for their coopera-tion, promptness, support, encouragement, and confidence in the project.

    Finally, I must confess that any errors that may yet remain are my own respon-sibility. However, I would appreciate hearing about any inadvertent errors, alternatesolutions, or, better yet, exercises you have enjoyed.

    Thomas [email protected]

  • A Word to the Student

    Mathematics is music for the mind;

    music is mathematics for the soul.

    ANONYMOUS

    The Language of Mathematics

    To learn a language, you have to know its alphabet, grammar, and syntax, and youhave to develop a decent vocabulary. Likewise, mathematics is a language with itsown symbols, rules, terms, definitions, and theorems. To be successful in mathe-matics, you must know them and be able to apply them; you must develop a work-ing vocabulary, use it as often as you can, and speak and write in the language ofmath.

    This book was written with you in mind, to create an introduction to numbertheory that is easy to understand. Each chapter is divided into short sections of ap-proximately the same length.

    Problem-Solving Techniques

    Throughout, the book emphasizes problem-solving techniques such as doing ex-periments, collecting data, organizing them in an orderly fashion, recognizing pat-terns, and making conjectures. It also emphasizes recursion, an extremely powerfulproblem-solving strategy used heavily in both mathematics and computer science.Although you may need some practice to get used to recursion, once you know howto approach problems recursively, you will appreciate its power and beauty. So donot be turned off, even if you have to struggle a bit with it initially.

    The book stresses proof techniques as well. Theorems are the bones of math-ematics. So, for your convenience, the various proof methods are explained and il-lustrated in the Appendix. It is strongly recommended that you master them; do theworked-out examples, and then do the exercises. Keep reviewing the techniques asoften as needed.

    Many of the exercises use the theorems and the techniques employed in theirproofs. Try to develop your own proofs. This will test your logical thinking and

    xxi

  • xxii A Word to the Student

    analytical skills. In order to fully enjoy this beautiful and elegant subject, you mustfeel at home with the various proof methods.

    Getting Involved

    Basketball players such as Michael Jordan and Larry Bird did not become super-stars by reading about basketball or watching others play. Besides knowing the rulesand the objects needed to play, they needed countless hours of practice, hard work,and determination to achieve their goal. Likewise, you cannot learn mathematics bysimply watching your professor do it in class or by reading about it; you have todo it yourself every day, just as skill is acquired in a sport. You can learn mathe-matics in small, progressive steps only, building on skills you already have devel-oped.

    Suggestions for Learning

    Here are a few suggestions you should find useful in your pursuit:

    Read a few sections before each class. You might not fully understand the ma-terial, but you will certainly follow it far better when your professor discussesit in class. Besides, you will be able to ask more questions in class and answermore questions.

    Always go to class well prepared. Be prepared to answer and ask questions. Whenever you study from the book, make sure you have a pencil and enough

    scrap paper next to you for writing the definitions, theorems, and proofs andfor doing the exercises.

    Study the material taught in class on the same day. Do not just read it as if youwere reading a novel or a newspaper. Write down the definitions, theorems,and properties in your own words without looking in your notes or the book.Rewrite the examples, proofs, and exercises done in class, all in your ownwords. If you cannot do them on your own, study them again and try again;continue until you succeed.

    Always study the relevant section in the text and do the examples there, thendo the exercises at the end of the section. Since the exercises are graded inorder of difficulty, do them in order. Do not skip steps or write over previoussteps; this way you will be able to progress logically, locate your errors, andcorrect your mistakes. If you cannot solve a problem because it involves anew term, formula, or some property, then re-study the relevant portion ofthe section and try again. Do not assume that you will be able to do everyproblem the first time you try it. Remember, practice is the best shortcut tosuccess.

  • A Word to the Student xxiii

    Solutions Manual

    The Students Solutions Manual contains additional tips for studying mathematics,preparing for an examination in mathematics, and taking an examination in mathe-matics. It also contains detailed solutions to all even-numbered exercises.

    A Final Word

    Mathematics, especially number theory, is no more difficult than any other subject.If you have the willingness, patience, and time to sit down and do the work, then youwill find number theory worth studying and this book worth studying from; you willfind that number theory can be fun, and fun can be number theory. Remember thatlearning mathematics is a step-by-step matter. Do your work regularly and system-atically; review earlier chapters every week, since things must be fresh in your mindto apply them and to build on them. In this way, you will enjoy the subject and feelconfident to explore more. I look forward to hearing from you with your commentsand suggestions. In the meantime, enjoy the book.

    Thomas Koshy

  • 1 FundamentalsTell me and I will forget.

    Show me and I will remember.

    Involve me and I will understand.

    CONFUCIUS

    he outstanding German mathematician Karl Friedrich Gauss (17771855)Tonce said, Mathematics is the queen of the sciences and arithmetic the queenof mathematics. Arithmetic, in the sense Gauss uses it, is number theory,which, along with geometry, is one of the two oldest branches of mathematics. Num-ber theory, as a fundamental body of knowledge, has played a pivotal role in thedevelopment of mathematics. And as we will see in the chapters ahead, the study ofnumber theory is elegant, beautiful, and delightful.

    A remarkable feature of number theory is that many of its results are within thereach of amateurs. These results can be studied, understood, and appreciated with-out much mathematical sophistication. Number theory provides a fertile ground forboth professionals and amateurs. We can also find throughout number theory manyfascinating conjectures whose proofs have eluded some of the most brilliant mathe-maticians. We find a great number of unsolved problems as well as many intriguingresults.

    Another interesting characteristic of number theory is that although many of itsresults can be stated in simple and elegant terms, their proofs are sometimes longand complicated.

    Generally speaking, we can define number theory as the study of the propertiesof numbers, where by numbers we mean integers and, more specifically, positiveintegers.

    Studying number theory is a rewarding experience for several reasons. First, ithas historic significance. Second, integers, more specifically, positive integers, are

    1

  • 2 CHAPTER 1 Fundamentals

    A Greek StampHonoringPythagoras

    The Island of Samos

    Pythagoras (ca. 572ca. 500 B.C.), a Greek philoso-pher and mathematician, was born on the Aegean is-

    land of Samos. After extensive travel and studies, he

    returned home around 529 B.C. only to find that Samos

    was under tyranny, so he migrated to the Greek port

    of Crontona, now in southern Italy. There he founded

    the famous Pythagorean school among the aristo-

    crats of the city. Besides being an academy for phi-

    losophy, mathematics, and natural science, the school

    became the center of a closely knit brotherhood shar-

    ing arcane rites and observances. The brotherhood

    ascribed all its discoveries to the master.A philosopher, Pythagoras taught that number was the essence of everything, and

    he associated numbers with mystical powers. He also believed in the transmigration of the

    soul, an idea he might have borrowed from the Hindus.

    Suspicions arose about the brotherhood, leading to the murder of most of its members. The school was

    destroyed in a political uprising. It is not known whether Pythagoras escaped death or was killed.

    the building blocks of the real number system, so they merit special recognition.Third, the subject yields great beauty and offers both fun and excitement. Finally,the many unsolved problems that have been daunting mathematicians for centuriesprovide unlimited opportunities to expand the frontiers of mathematical knowledge.Goldbachs conjecture (Section 2.5) and the existence of odd perfect numbers (Sec-tion 8.3) are two cases in point. Modern high-speed computers have become a pow-erful tool in proving or disproving such conjectures.

    Although number theory was originally studied for its own sake, today it hasintriguing applications to such diverse fields as computer science and cryptography(the art of creating and breaking codes).

    The foundations for number theory as a discipline were laid out by the Greekmathematician Pythagoras and his disciples (known as the Pythagoreans). ThePythagorean brotherhood believed that everything is number and that the centralexplanation of the universe lies in number. They also believed some numbers havemystical powers. The Pythagoreans have been credited with the invention of am-icable numbers, perfect numbers, figurate numbers, and Pythagorean triples. Theyclassified integers into odd and even integers, and into primes and composites.

    Another Greek mathematician, Euclid (ca. 330275 B.C.), also made significantcontributions to number theory. We will find many of his results in the chapters tofollow.

    We begin our study of number theory with a few fundamental properties of in-tegers.

  • 1.1 Fundamental Properties 3

    Little is known about Euclids life. He was on the faculty at the University of Alexan-dria and founded the Alexandrian School of Mathematics. When the Egyptian ruler

    King Ptolemy I asked Euclid, the father of geometry, if there were an easier way to

    learn geometry than by studying The Elements, he replied, There is no royal road

    to geometry.

    1.1 Fundamental Properties

    The German mathematician Hermann Minkowski (18641909) once remarked, In-tegral numbers are the fountainhead of all mathematics. We will come to appreciatehow important his statement is. In fact, number theory is concerned solely with inte-gers. The set of integers is denoted by the letter Z:

    Z = {. . . ,3,2,1,0,1,2,3, . . .}

    Whenever it is convenient, we write x S to mean x belongs to the set S;x / S means x does not belong to S. For example, 3 Z, but 3 / Z.

    We can represent integers geometrically on the number line, as in Figure 1.1.

    Figure 1.1

    The integers 1,2,3, . . . are positive integers. They are also called natural num-bers or counting numbers; they lie to the right of the origin on the number line. Wedenote the set of positive integers by Z+ or N:

    Z+ = N = {1,2,3, . . .}

    The letter Z comes from the German word Zahlen for numbers.

  • 4 CHAPTER 1 Fundamentals

    Leopold Kronecker (18231891) was born in 1823 into a well-to-do family in Liegnitz,Prussia (now Poland). After being tutored privately at home during his early years and

    then attending a preparatory school, he went on to the local gymnasium, where he

    excelled in Greek, Latin, Hebrew, mathematics, and philosophy. There he was fortu-

    nate to have the brilliant German mathematician Ernst Eduard Kummer (18101893)

    as his teacher. Recognizing Kroneckers mathematical talents, Kummer encouraged

    him to pursue independent scientific work. Kummer later became his professor at the

    universities of Breslau and Berlin.

    In 1841, Kronecker entered the University of Berlin and also spent time at the

    University of Breslau. He attended lectures by Dirichlet, Jacobi, Steiner, and Kummer.

    Four years later he received his Ph.D. in mathematics.

    Kroneckers academic life was interrupted for the next 10 years when he ran his uncles business. Nonethe-

    less, he managed to correspond regularly with Kummer. After becoming a member of the Berlin Academy of

    Sciences in 1861, Kronecker began his academic career at the University of Berlin, where he taught unpaid until

    1883; he became a salaried professor when Kummer retired.

    In 1891, his wife died in a fatal mountain climbing accident, and Kronecker, devastated by the loss, suc-

    cumbed to bronchitis and died four months later.

    Kronecker was a great lover of the arts, literature, and music, and also made profound contributions to num-

    ber theory, the theory of equations, elliptic functions, algebra, and the theory of determinants. The vertical bar

    notation for determinants is his creation.

    The German mathematician Leopold Kronecker wrote, God created the naturalnumbers and all else is the work of man. The set of positive integers, together with 0,forms the set of whole numbers W:

    W = {0,1,2,3, . . .}

    Negative integers, namely, . . . ,3,2,1, lie to the left of the origin. Noticethat 0 is neither positive nor negative.

    We can employ positive integers to compare integers, as the following definitionshows.

    The Order RelationLet a and b be any two integers. Then a is less than b, denoted by a < b, if thereexists a positive integer x such that a + x = b, that is, if b a is a positive integer.When a < b, we also say that b is greater than a, and we write b > a.

    The symbols < and > were introduced in 1631 by the English mathematician Thomas Harriet(15601621).

  • 1.1 Fundamental Properties 5

    If a is not less than b, we write a b; similarly, a b indicates a is not greaterthan b.

    It follows from this definition that an integer a is positive if and only if a > 0.Given any two integers a and b, there are three possibilities: either a < b, a = b,

    or a > b. This is the law of trichotomy. Geometrically, this means if a and b are anytwo points on the number line, then either point a lies to the left of point b, the twopoints are the same, or point a lies to the right of point b.

    We can combine the less than and equality relations to define the less than orequal to relation. If a < b or a = b, we write a b. Similarly, a b means eithera > b or a = b. Notice that a < b if and only if a b.

    We will find the next result useful in Section 3.4. Its proof is fairly simple and isan application of the law of trichotomy.

    THEOREM 1.1 Let min{x, y} denote the minimum of the integers x and y, and max{x, y} their maxi-mum. Then min{x, y} + max{x, y} = x + y.

    PROOF (by cases)case 1 Let x y. Then min{x, y} = x and max{x, y} = y, so min{x, y}+max{x, y} =x + y.case 2 Let x > y. Then min{x, y} = y and max{x, y} = x, so min{x, y}+max{x, y} =y + x = x + y.

    The law of trichotomy helps us to define the absolute value of an integer.

    Absolute ValueThe absolute value of a real number x, denoted by |x|, is defined by

    |x| ={

    x if x 0x otherwise

    For example, |5| = 5, |3| = (3) = 3, | | = , and |0| = 0.Geometrically, the absolute value of a number indicates its distance from the

    origin on the number line.Although we are interested only in properties of integers, we often need to

    deal with rational and real numbers also. Floor and ceiling functions are two suchnumber-theoretic functions. They have nice applications to discrete mathematics andcomputer science.

    The symbols and were introduced in 1734 by the French mathematician P. Bouguer. A theorem is a (major) result that can be proven from axioms or previously known results. Theorem 1.1 is true even if x and y are real numbers.

  • 6 CHAPTER 1 Fundamentals

    Floor and Ceiling FunctionsThe floor of a real number x, denoted by x, is the greatest integer x. The ceilingof x, denoted by x, is the least integer x. The floor of x rounds down x, whereasthe ceiling of x rounds up. Accordingly, if x / Z, the floor of x is the nearest integer tothe left of x on the number line, and the ceiling of x is the nearest integer to the rightof x, as Figure 1.2 shows. The floor function f (x) = x and the ceiling functiong(x) = x are also known as the greatest integer function and the least integerfunction, respectively.

    Figure 1.2

    For example, = 3, log10 3 = 0, 3.5 = 4, 2.7 = 3, = 4,log10 3 = 1, 3.5 = 3, and 2.7 = 2.

    The floor function comes in handy when real numbers are to be truncated orrounded off to a desired number of decimal places. For example, the real number =3.1415926535 . . . truncated to three decimal places is given by 1000/1000 =3141/1000 = 3.141; on the other hand, rounded to three decimal places is1000 + 0.5/1000 = 3.142.

    There is yet another simple application of the floor function. Suppose we dividethe unit interval [0,1) into 50 subintervals of equal length 0.02 and then seek todetermine the subinterval that contains the number 0.4567. Since 0.4567/0.02 +1 = 23, it lies in the 23rd subinterval. More generally, let 0 x < 1. Then x lies inthe subinterval x/0.02 + 1 = 50x + 1.

    The following example presents an application of the ceiling function to every-day life.

    EXAMPLE 1.1 (The post-office function) In 2006, the postage rate in the United States for a first-class letter of weight x, not more than one ounce, was 39; the rate for each additionalounce or a fraction thereof up to 11 ounces was an additional 24. Thus, the postagep(x) for a first-class letter can be defined as p(x) = 0.39 + 0.24x 1, 0 < x 11.

    For instance, the postage for a letter weighing 7.8 ounces is p(7.8) = 0.39 +0.247.8 1 = $2.07.

    These two notations and the names, floor and ceiling, were introduced by Kenneth E. Iverson in theearly 1960s. Both notations are variations of the original greatest integer notation [x].

  • 1.1 Fundamental Properties 7

    Some properties of the floor and ceiling functions are listed in the next theorem.We shall prove one of them; the others can be proved as routine exercises.

    THEOREM 1.2 Let x be any real number and n any integer. Then

    1. n = n = n

    2. x = x + 1 (x / Z)3. x + n = x + n4. x + n = x + n

    5.

    n

    2

    = n 12

    if n is odd.

    6.

    n

    2

    = n + 12

    if n is odd.

    PROOF

    Every real number x can be written as x = k + x, where k = x and 0 x < 1. SeeFigure 1.3. Then

    Figure 1.3

    x + n = k + n + x = (k + n) + xx + n = k + n, since 0 x < 1

    = x + n

    E X E R C I S E S 1.1

    1. The English mathematician Augustus DeMorgan,who lived in the 19th century, once remarked that hewas x years old in the year x2. When was he born?

    Evaluate each, where x is a real number.2. f (x) = x|x| (x = 0)3. g(x) = x + x4. h(x) = x + x

    Determine whether:5. x = x6. x = x

    7. There are four integers between 100 and 1000 that are

    each equal to the sum of the cubes of its digits. Threeof them are 153, 371, and 407. Find the fourth num-ber. (Source unknown.)

    8. An n-digit positive integer N is a Kaprekar numberif the sum of the number formed by the last n digitsin N2, and the number formed by the first n (or n 1)digits in N2 equals N. For example, 297 is a Kaprekarnumber since 2972 = 88209 and 88 + 209 = 297.There are five Kaprekar numbers < 100. Find them.

    9. Find the flaw in the following proof:Let a and b be real numbers such that a = b. Then

    ab = b2a2 ab = a2 b2

    Factoring, a(a b) = (a + b)(a b). Cancelinga b from both sides, a = a + b. Since a = b,this yields a = 2a. Canceling a from both sides,we get 1 = 2.

  • 8 CHAPTER 1 Fundamentals

    D. R. Kaprekar (19051986) was born in Dahanu, India, near Bombay. After losing his mother at the age ofeight, he built a close relationship with his astrologer-father, who passed on his knowledge to his son. He at-

    tended Ferguson College in Pune, and then graduated from the University of Bombay in 1929. He was awarded

    the Wrangler R. P. Paranjpe prize in 1927 in recognition of his mathematical contributions. A prolific writer in

    recreational number theory, he worked as a schoolteacher in Devlali, India, from 1930 until his retirement in

    1962.

    Kaprekar is best known for his 1946 discovery of the Kaprekar constant 6174. It took him about threeyears to discover the number: Take a four-digit number a, not all digits being the same; let a denote the numberobtained by rearranging its digits in nondecreasing order and a denote the number obtained by rearranging itsdigits in nonincreasing order. Repeat these steps with b = a a and its successors. Within a maximum of eightsteps, this process will terminate in 6174. It is the only integer with this property.

    10. Express 635,318,657 as the sum of two fourth powersin two different ways. (It is the smallest number withthis property.)

    11. The integer 1105 can be expressed as the sum of twosquares in four different ways. Find them.

    12. There is exactly one integer between 2 and 2 1014that is a perfect square, a cube, and a fifth power. Findit. (A. J. Friedland, 1970)

    13. The five-digit number 2xy89 is the square of an in-teger. Find the two-digit number xy. (Source: Mathe-matics Teacher)

    14. How many perfect squares can be displayed on a 15-digit calculator?

    15. The number sequence 2,3,5,6,7,10,11, . . . consistsof positive integers that are neither squares nor cubes.Find the 500th term of this sequence. (Source: Math-ematics Teacher)

    Prove each, where a, b, and n are any integers, and x is areal number.16. |ab| = |a| |b|17. |a + b| |a| + |b|18.

    n

    2

    = n 12

    if n is odd.

    19.

    n

    2

    = n + 12

    if n is odd.

    20.

    n2

    4

    = n2 1

    4if n is odd.

    21.

    n2

    4

    = n2 + 3

    4if n is odd.

    22.

    n

    2

    +

    n

    2

    = n23. x = x + 1 (x / Z)24. x = x25. x + n = x + n26. x + x + 1/2 = 2x27. x/n = x/nThe distance from x to y on the number line, denoted byd(x, y), is defined by d(x, y) = |y x|. Prove each, wherex, y, and z are any integers.28. d(x, y) 029. d(0, x) = |x|30. d(x, y) = 0 if and only if x = y31. d(x, y) = d(y, x)32. d(x, y) d(x, z) + d(z, y)33. Let max{x, y} denote the maximum of x and y, and

    min{x, y} their minimum, where x and y are any inte-gers. Prove that max{x, y} min{x, y} = |x y|.

    34. A round-robin tournament has n teams, and each teamplays at most once in a round. Determine the mini-mum number of rounds f (n) needed to complete thetournament. (Romanian Olympiad, 1978)

  • 1.2 The Summation and Product Notations 9

    Joseph Louis Lagrange (17361813), who ranks with Leonhard Euler as one of thegreatest mathematicians of the 18th century, was the eldest of eleven children in a

    wealthy family in Turin, Italy. His father, an influential cabinet official, became bank-

    rupt due to unsuccessful financial speculations, which forced Lagrange to pursue a

    profession.

    As a young man studying the classics at the College of Turin, his interest in math-

    ematics was kindled by an essay by astronomer Edmund Halley on the superiority of

    the analytical methods of calculus over geometry in the solution of optical problems.

    In 1754 he began corresponding with several outstanding mathematicians in Europe.

    The following year, Lagrange was appointed professor of mathematics at the Royal

    Artillery School in Turin. Three years later, he helped to found a society that later

    became the Turin Academy of Sciences. While at Turin, Lagrange developed revolu-

    tionary results in the calculus of variations, mechanics, sound, and probability, winning the prestigious Grand Prix

    of the Paris Academy of Sciences in 1764 and 1766.

    In 1766, when Euler left the Berlin Academy of Sciences, Frederick the Great wrote to Lagrange that the

    greatest king in Europe would like to have the greatest mathematician of Europe at his court. Accepting the

    invitation, Lagrange moved to Berlin to head the Academy and remained there for 20 years. When Frederick died

    in 1786, Lagrange moved to Paris at the invitation of Louis XVI. Lagrange was appointed professor at the cole

    Normale and then at the cole Polytechnique, where he taught until 1799.

    Lagrange made significant contributions to analysis, analytical mechanics, calculus, probability, and number

    theory, as well as helping to set up the French metric system.

    1.2 The Summation and Product Notations

    We will find both the summation and the product notations very useful throughoutthe remainder of this book. First, we turn to the summation notation.

    The Summation NotationSums, such as ak + ak+1 + + am, can be written in a compact form using thesummation symbol

    (the Greek uppercase letter sigma), which denotes the word

    sum. The summation notation was introduced in 1772 by the French mathematicianJoseph Louis Lagrange.

    A typical term in the sum above can be denoted by ai, so the above sum is the

    sum of the numbers ai as i runs from k to m and is denoted byi=mi=k

    ai. Thus

    i=m

    i=kai = ak + ak+1 + + am

  • 10 CHAPTER 1 Fundamentals

    The variable i is the summation index. The values k and m are the lower and upperlimits of the index i. The i = above the is usually omitted:

    i=m

    i=kai =

    m

    i=kai

    For example,

    2

    i=1i(i 1) = (1)(1 1) + 0(0 1) + 1(1 1) + 2(2 1) = 4

    The index i is a dummy variable; we can use any variable as the index withoutaffecting the value of the sum, so

    m

    i=ai =

    m

    j=aj =

    m

    k=ak

    EXAMPLE 1.2 Evaluate3

    j=2j2.

    SOLUTION

    3

    j=2j2 = (2)2 +(1)2 +02 +12 +22 +32 = 19

    The following results are extremely useful in evaluating finite sums. They canbe proven using mathematical induction, presented in Section 1.3.

    THEOREM 1.3 Let n be any positive integer and c any real number, and a1,a2, . . . ,an and b1,b2, . . . ,bn any two number sequences. Then

    n

    i=1c = nc (1.1)

  • 1.2 The Summation and Product Notations 11

    n

    i=1(cai) = c

    (n

    i=1ai

    )

    (1.2)

    n

    i=1(ai + bi) =

    n

    i=1ai +

    n

    i=1bi (1.3)

    (These results can be extended to any lower limit k Z.)

    The following example illustrates this theorem.

    EXAMPLE 1.3 Evaluate2

    j=1[(5j)3 2j].

    SOLUTION

    2

    j=1[(5j)3 2j] =

    2

    j=1(5j)3 2

    (2

    j=1j

    )

    = 125(

    2

    j=1j3

    )

    22

    j=1j

    = 125[(1)3 + 03 + 13 + 23] 2(1 + 0 + 1 + 2)= 996

    Indexed Summation

    The summation notation can be extended to sequences with index sets I as theirdomains. For instance,

    iIai denotes the sum of the values of ai as i runs over the

    various values in I.As an example, let I = {0,1,3,5}. Then

    iI(2i + 1) represents the sum of the

    values of 2i + 1 with i I, so

    iI(2i + 1) = (2 0 + 1) + (2 1 + 1) + (2 3 + 1) + (2 5 + 1) = 22

    Often we need to evaluate sums of the form

    Paij, where the subscripts i and j

    satisfy certain properties P. (Such summations are used in Chapter 8.)

  • 12 CHAPTER 1 Fundamentals

    For example, let I = {1,2,3,4}. Then 1i

  • 1.2 The Summation and Product Notations 13

    =1

    i=1(6i + 9)

    = [6 (1) + 9] + (6 0 + 9) + (6 1 + 9)= 27

    We now turn to the product notation.

    The Product Notation

    Just as

    is used to denote sums, the product akak+1 am is denoted byi=mi=k

    ai. The

    product symbol

    is the Greek capital letter pi. As in the case of the summationnotation, the i = above the product symbol is often dropped:

    i=m

    i=kai =

    m

    i=kai = akak+1 am

    Again, i is just a dummy variable.The following three examples illustrate this notation.The factorial function, which often arises in number theory, can be defined

    using the product symbol, as the following example shows.

    EXAMPLE 1.6 The factorial function f (n) = n! (read n factorial) is defined by n! = n(n1) 2 1,where 0! = 1. Using the product notation, f (n) = n! =

    n

    k=1k.

    EXAMPLE 1.7 Evaluate5

    i=2(i2 3).

    SOLUTION

    5

    i=2(i2 3) = (22 3)(32 3)(42 3)(52 3)

    = 1 6 13 22 = 1716

  • 14 CHAPTER 1 Fundamentals

    Just as we can have indexed summation, we can also have indexed multiplica-tion, as the following example shows.

    EXAMPLE 1.8 Evaluate

    i,jIi

  • 1.3 Mathematical Induction 15

    28.50

    k=0(1)k

    Evaluate each, where p {2,3,5,7,11,13} andI = {1,2,3,5}.29.

    3

    k=0k! 30.

    p10p

    31.

    p10p 32.

    iI(3i 1)

    33.

    d1d|12

    d 34.

    d1d|12

    (12

    d

    )

    35.

    d1d|18

    1 36.

    p101

    37.

    i,jIi

  • 16 CHAPTER 1 Fundamentals

    n

    i=1i = n(n + 1)

    2

    n1i=0

    ri = rn 1r 1 (r = 1)

    How do we prove that these results hold for every positive integer n? Obviously,it is impossible to substitute each positive integer for n and verify that the formulaholds. The principle of induction can establish the validity of such formulas.

    Before we plunge into induction, we need the well-ordering principle, which weaccept as an axiom. (An axiom is a statement that is accepted as true; it is consistentwith known facts; often it is a self-evident statement.)

    The Well-Ordering Principle

    Every nonempty set of positive integers has a least element.For example, the set {17,23,5,18,13} has a least element, namely, 5. The ele-

    ments of the set can be ordered as 5, 13, 17, 18, and 23.By virtue of the well-ordering principle, the set of positive integers is well or-

    dered. You may notice that the set of negative integers is not well ordered.The following example is a simple application of the well-ordering principle.

    EXAMPLE 1.9 Prove that there is no positive integer between 0 and 1.

    PROOF (by contradiction)Suppose there is a positive integer a between 0 and 1. Let S = {n Z+ | 0 < n < 1}.Since 0 < a < 1,a S, so S is nonempty. Therefore, by the well-ordering principle,S has a least element , where 0 < < 1. Then 0 < 2 < , so 2 S. But 2 < ,which contradicts our assumption that is a least element of S. Thus, there are nopositive integers between 0 and 1.

    The well-ordering principle can be extended to whole numbers also, as the fol-lowing example shows.

    EXAMPLE 1.10 Prove that every nonempty set of nonnegative integers has a least element.

    PROOF (by cases)Let S be a set of nonnegative integers.

    case 1 Suppose 0 S. Since 0 is less than every positive integer, 0 is less thanevery nonzero element in S, so 0 is a least element in S.

  • 1.3 Mathematical Induction 17

    case 2 Suppose 0 / S. Then S contains only positive integers. So, by the well-ordering principle, S contains a least element.

    Thus, in both cases, S contains a least element.

    Weak Version of InductionThe following theorem is the cornerstone of the principle of induction.

    THEOREM 1.4 Let S be a set of positive integers satisfying the following properties:

    1. 1 S.2. If k is an arbitrary positive integer in S, then k + 1 S.

    Then S = N.

    PROOF (by contradiction)Suppose S = N. Let S = {n N | n / S}. Since S = , by the well-ordering prin-ciple, S contains a least element . Then > 1 by condition (1). Since is theleast element in S, 1 / S. Therefore, 1 S. Consequently, by condition (2),( 1) + 1 = S. This contradiction establishes the theorem.

    This result can be generalized, as the following theorem shows. We leave itsproof as an exercise.

    THEOREM 1.5 Let n0 be a fixed integer. Let S be a set of integers satisfying the following conditions:

    n0 S. If k is an arbitrary integer n0 such that k S, then k + 1 S.

    Then S contains all integers n n0.

    Before we formalize the principle of induction, lets look at a trivial example.Consider an infinite number of identical dominoes arranged in a row at varying dis-tances from each other, as in Figure 1.4(a). Suppose we knock down the first domino.What happens to the rest of the dominoes? Do they all fall? Not necessarily. See Fig-ures 1.4(b) and 1.4(c).

    So let us assume the following: The dominoes are placed in such a way that thedistance between two adjacent dominoes is less than the length of a domino; the firstdomino falls; and if the kth domino falls, then the (k + 1)st domino also falls. Thenthey all would fall. See Figure 1.4(d).

    This illustration can be expressed symbolically. Let P(n) denote the statementthat the nth domino falls. Assume the following statements are true:

  • 18 CHAPTER 1 Fundamentals

    Figure 1.4

    P(1). P(k) implies P(k + 1) for an arbitrary positive integer k.

    Then P(n) is true for every positive integer n; that is, every domino would fall. Thisis the essence of the following weak version of the principle.

    THEOREM 1.6 (The Principle of Mathematical Induction) Let P(n) be a statement satisfyingthe following conditions, where n Z:

    1. P(n0) is true for some integer n0.2. If P(k) is true for an arbitrary integer k n0, then P(k + 1) is also true.

    Then P(n) is true for every integer n n0.

    PROOF

    Let S denote the set of integers n0 for which P(n) is true. Since P(n0) is true,n0 S. By condition (2), whenever k S, k + 1 S, so, by Theorem 1.5, S containsall integers n0. Consequently, P(n) is true for every integer n n0.

    Condition (1) in Theorem 1.6 assumes the proposition P(n) is true when n = n0.Look at condition (2): If P(n) is true for an arbitrary integer k n0, it is also true forn = k + 1. Then, by repeated application of condition (2), it follows that P(n0 + 1),P(n0 + 2), . . . hold true. In other words, P(n) holds for every n n0.

    Theorem 1.6 can be established directly from the well-ordering principle. SeeExercise 44.

  • 1.3 Mathematical Induction 19

    Proving a result by induction involves two key steps:

    basis step Verify that P(n0) is true. induction step Assume P(k) is true for an arbitrary integer k n0

    (inductive hypothesis).Then verify that P(k + 1) is also true.

    A word of caution: A question frequently asked is, Isnt this circular reasoning?Arent we assuming what we are asked to prove? In fact, no. The confusion stemsfrom misinterpreting step 2 for the conclusion. The induction step involves showingthat P(k) implies P(k + 1); that is, if P(k) is true, then so is P(k + 1). The conclusionis P(n) is true for every n n0. So be careful.

    Interestingly, there were television commercials for Crest toothpaste based oninduction involving toothpastes and penguins.

    Some examples will show how useful this important proof technique is.

    EXAMPLE 1.11 Prove that

    1 + 2 + 3 + + n = n(n + 1)2

    (1.4)

    for every positive integer n.

    PROOF (by induction)

    Let P(n) be the statement thatn

    i=1i = [n(n + 1)]/2.

    basis step To verify that P(1) is true (note: Here n0 = 1):When n = 1, RHS = [1(1 + 1)]/2 = 1 =

    1

    i=1i = LHS. Thus, P(1) is true.

    LHS and RHS are abbreviations of left-hand side and right-hand side, respectively.

  • 20 CHAPTER 1 Fundamentals

    induction step Let k be an arbitrary positive integer. We would like to show thatP(k) implies P(k + 1). Assume P(k) is true; that is,

    k

    i=1i = k(k + 1)

    2 inductive hypothesis

    To show that P(k) implies P(k + 1), that is,k+1i=1

    i = [(k + 1)(k + 2)]/2, we start withthe LHS of this equation:

    LHS =k+1

    i=1i =

    k

    i=1i + (k + 1)

    [

    Note:k+1

    i=1xi =

    (k

    i=1xi

    )

    + xk+1.]

    = k(k + 1)2

    + (k + 1), by the inductive hypothesis

    = (k + 1)(k + 2)2

    = RHS

    So, if P(k) is true, then P(k + 1) is also true.Thus, by induction, P(n) is true for every integer n 1; that is, the formula holds

    for every positive integer.

    Figure 1.5 demonstrates formula (1.4) without words.

    Figure 1.5

    Often we arrive at a formula by studying patterns, then making a conjecture, andthen establishing the formula by induction, as the following example shows.

    EXAMPLE 1.12 Conjecture a formula for the sum of the first n odd positive integers and then useinduction to establish the conjecture.

  • 1.3 Mathematical Induction 21

    SOLUTION

    First, we study the first five such sums, and then look for a pattern, to predict aformula for the sum of the first n odd positive integers.

    The first five such sums are

    1 = 121 + 3 = 22

    1 + 3 + 5 = 321 + 3 + 5 + 7 = 42

    1 + 3 + 5 + 7 + 9 = 52

    There is a clear pattern here, so we conjecture that the sum of the first n odd positiveintegers is n2; that is,

    n

    i=1(2i 1) = n2 (1.5)

    We shall now prove it by the principle of induction.

    PROOF

    When n = 1,n

    i=1(2i 1) =

    1

    i=1(2i 1) = 1 = 12, so the result holds when n = 1.

    Now, assume the formula holds when n = k:k

    i=1(2i 1) = k2. To show that it

    holds when n = k + 1, consider the sumk+1i=1

    (2i 1). We havek+1

    i=1(2i 1) =

    k

    i=1(2i 1) + [2(k + 1) 1]

    = k2 + (2k + 1) by the inductive hypothesis= (k + 1)2

    Consequently, if the formula holds when n = k, it is also true when n = k + 1.Thus, by induction, the formula holds for every positive integer n.

    Figure 1.6 provides a visual illustration of formula (1.5).

    Figure 1.6

  • 22 CHAPTER 1 Fundamentals

    Returning to induction, we find that both the basis and the induction steps are essen-tial in the induction proof, as the following two examples demonstrate.

    EXAMPLE 1.13 Consider the formula 1 + 3 + 5 + + (2n 1) = (n 2)2. Clearly it is true whenn = 1. But it is not true when n = 2.

    Conclusion? That the truth of the basis step does not ensure that the statement1 + 3 + 5 + + (2n 1) = (n 2)2 is true for every n.

    The following example shows that the validity of the induction step is necessary,but not sufficient, to guarantee that P(n) is true for all desired integers.

    EXAMPLE 1.14 Consider the formula P(n): 1 + 3 + 5 + + (2n 1) = n2 + 1. Suppose P(k) istrue:

    k

    i=1(2i 1) = k2 + 1. Then

    k+1

    i=1(2i 1) =

    k

    i=1(2i 1) + [2(k + 1) 1]

    = (k2 + 1) + (2k + 1)= (k + 1)2 + 1

    So if P(k) is true, P(k + 1) is true. Nevertheless, the formula does not hold for anypositive integer n. Try P(1).

    An interesting digression: Using induction, we prove in the following examplethat every person is of the same sex.

    EXAMPLE 1.15 Prove that every person in a set of n people is of the same sex.

    PROOF

    Let P(n): Everyone in a set of n people is of the same sex. Clearly, P(1) is true. Letk be a positive integer such that P(k) is true; that is, everyone in a set of k people isof the same sex.

    To show that P(k + 1) is true, consider a set A = {a1,a2, . . . ,ak+1} of k + 1people. Partition A into two overlapping sets, B = {a1, a2, . . . , ak} and C =

  • 1.3 Mathematical Induction 23

    {a2, . . . ,ak+1}, as in Figure 1.7. Since B and C contain k elements, by the induc-tive hypothesis, everyone in B is of the same sex and everyone in C is of the samesex. Since B and C overlap, everyone in B C must be of the same sex; that is,everyone in A is of the same sex.

    Figure 1.7

    Therefore, by induction, P(n) is true for every positive integer n.

    Note: Clearly the assertion that everyone is of the same sex is false. Can you find theflaw in the proof? See Exercise 35.

    Strong Version of Induction

    We now present the stronger version of induction.Sometimes the truth of P(k) might not be enough to establish that of P(k + 1).

    In other words, the truth of P(k + 1) may require more than that of P(k). In suchcases, we assume a stronger inductive hypothesis that P(n0),P(n0 + 1), . . . ,P(k) areall true; then verify that P(k + 1) is also true. This strong version, which can beproven using the weak version (see Exercise 43), is stated as follows.

    THEOREM 1.7 (The Second Principle of Mathematical Induction) Let P(n) be a statement sat-isfying the following conditions, where n Z:

    1. P(n0) is true for some integer n0.

    B C denotes the union of the sets B and C; it contains the elements in B together with those in C.

  • 24 CHAPTER 1 Fundamentals

    2. If k is an arbitrary integer n0 such that P(n0), P(n0 + 1), . . ., and P(k) aretrue, then P(k + 1) is also true.

    Then P(n) is true for every integer n n0.

    PROOF

    Let S = {n Z | P(n) is true}. Since P(n0) is true by condition (1), n0 S.Now, assume P(n0),P(n0 + 1), . . . ,P(k) are true for an arbitrary integer k. Then

    n0,n0 +1, . . . , k belong to S. So, by condition (2), k +1 also belongs to S. Therefore,by Theorem 1.5, S contains all integers n n0. In other words, P(n) is true for everyinteger n n0.

    The following example illustrates this proof technique.

    EXAMPLE 1.16 Prove that any postage of n ( 2) cents can be made with two- and three-cent stamps.

    PROOF (by strong induction)Let P(n) denote the statement that any postage of n cents can be made with two- andthree-cent stamps.

    basis step (Notice that here n0 = 2.) Since a postage of two cents can be madewith one two-cent stamp, P(2) is true. Likewise, P(3) is also true.

    induction step Assume P(2),P(3),P(4), . . . ,P(k) are true; that is, any postage oftwo through k cents can be made with two- and three-cent stamps.

    To show that P(k + 1) is true, consider a postage of k + 1 cents. Since k + 1 =(k 1)+2, a postage of k +1 cents can be formed with two- and three-cent stamps ifa postage of k 1 cents can be made with two- and three-cent stamps. Since P(k 1)is true by the inductive hypothesis, this implies P(k + 1) is also true.

    Thus, by the strong version of induction, P(n) is true for every n 2; that is, anypostage of n ( 2) cents can be made with two- and three-cent stamps.

    The following exercises and subsequent chapters offer ample practice in bothversions of induction.

    E X E R C I S E S 1.3

    Determine whether each set is well ordered. If it is not,explain why.

    1. Set of negative integers.2. Set of integers.

    3. {n N | n 5}4. {n Z | n 3}

    Prove each.5. Let a Z. There are no integers between a and a + 1.

  • 1.3 Mathematical Induction 25

    6. Let n0 Z, S a nonempty subset of the set T = {n Z | n n0}, and be a least element of the setT = {n n0 + 1 | n S}. Then n0 + 1 is a leastelement of S.

    7. (Archimedean property) Let a and b be any pos-itive integers. Then there is a positive integer n suchthat na b.(Hint: Use the well-ordering principle and contradic-tion.)

    8. Every nonempty set of negative integers has a largestelement.

    9. Every nonempty set of integers a fixed integer n0has a largest element.

    (Twelve Days of Christmas) Suppose you sent yourlove 1 gift on the first day of Christmas, 1 + 2 gifts on thesecond day, 1 + 2 + 3 gifts on the third day, and so on.10. How many gifts did you send on the 12th day of

    Christmas?11. How many gifts did your love receive in the 12 days

    of Christmas?12. Prove that 1 + 2 + + n = [n(n + 1)]/2 by con-

    sidering the sum in the reverse order. (Do not usemathematical induction.)

    Using mathematical induction, prove each for every inte-ger n 1.

    13.n

    i=1(2i 1) = n2

    14.n

    i=1i2 = n(n + 1)(2n + 1)

    6

    An interesting personal anecdote is told about Gauss. When

    Gauss was a fourth grader, he and his classmates were asked

    by his teacher to compute the sum of the first 100 positive inte-

    gers. Supposedly, the teacher did so to get some time to grade

    papers. To the teachers dismay, Gauss found the answer in a

    few moments by pairing the numbers from both ends:

    The sum of each pair is 101 and there are 50 pairs. So the total

    sum is 50 101 = 5050.

    15.n

    i=1i3 =

    [n(n + 1)

    2

    ]2

    16.n

    i=1ari1 = a(r

    n 1)r 1 , r = 1

    Evaluate each sum.

    17.30

    k=1(3k2 1) 18.

    50

    k=1(k3 + 2)

    19.n

    i=1i/2 20.

    n

    i=1i/2

    Find the value of x resulting from executing each algo-rithm fragment, where

    variable expressionmeans the value of expression is assigned to variable.

    21. x 0for i = 1 to n do

    x x + (2i 1)22. x 0

    for i = 1 to n dox x + i(i + 1)

    23. x 0for i = 1 to n do

    for j = 1 to i dox x + 1

    Evaluate each.

    24.n

    i=1

    i

    j=1i 25.

    n

    i=1

    i

    j=1j

    26.n

    i=1

    i

    j=1j2 27.

    n

    i=1

    i

    j=1(2j 1)

    28.n

    i=122i 29.

    n

    i=1i2

    30.n

    i=1

    n

    j=1i j 31.

    n

    i=1

    n

    j=12i+j

    32. A magic square of order n is a square arrangementof the positive integers 1 through n2 such that the sumof the integers along each row, column, and diagonalis a constant k, called the magic constant. Figure 1.8shows two magic squares, one of order 3 and the otherof order 4. Prove that the magic constant of a magic

    square of order n isn(n2 + 1)

    2.

  • 26 CHAPTER 1 Fundamentals

    Figure 1.8According to legend, King Shirham of India was sopleased by the invention of chess that he offeredto give Sissa Ben Dahir, its inventor, anything hewished. Dahirs request was a seemingly modest one:one grain of wheat on the first square of a chessboard,two on the second, four on the third, and so on. Theking was delighted with this simple request but soonrealized he could never fulfill it. The last square alonewould take 263 = 9,223,372,036,854,775,808 grainsof wheat. Find the following for an n n chessboard.

    33. The number of grains on the last square.34. The total number of grains on the chessboard.35. Find the flaw in the proof in Example 1.15.Find the number of times the assignment statementx x + 1 is executed by each loop.36. for i = 1 to n do

    for j = 1 to i dox x + 1

    37. for i = 1 to n dofor j = 1 to i do

    for k = 1 to i dox x + 1

    38. for i = 1 to n dofor j = 1 to i do

    for k = 1 to j dox x + 1

    39. for i = 1 to n dofor j = 1 to i do

    for k = 1 to i dofor l = 1 to i do

    x x + 140. Let an denote the number of times the statement

    x x + 1 is executed in the following loop:for i = 1 to n do

    for j = 1 to i/2 dox x + 1

    Show that an =

    n2

    4if n is even

    n2 14

    otherwise.

    Evaluate each.

    41.1024

    n=1lg n 42.

    1024

    n=1lg n

    43. Prove the strong version of induction, using theweak version.

    44. Prove the weak version of induction, using thewell-ordering principle.

    45. Let Sn denote the sum of the elements in the nthset of the sequence of sets of squares {1}, {4,9},{16,25,36}, . . .. Find a formula for Sn. (J. M. How-ell, 1989)

    1.4 Recursion

    Recursion is one of the most elegant problem-solving techniques. It is so powerfula tool that most programming languages support it.

    We begin with the well-known handshake problem:

    There are n guests at a party. Each person shakes hands with everybody else exactly once. How manyhandshakes are made?

  • 1.4 Recursion 27

    If we decide to solve a problem such as this, the solution may not be obvious.However, it is possible that the problem could be defined in terms of a simpler ver-sion of itself. Such a definition is an inductive definition. Consequently, the givenproblem can be solved provided the simpler version can be solved. This idea is pic-torially represented in Figure 1.9.

    Figure 1.9

    Recursive Definition of a Function

    Let a W and X = {a,a + 1,a + 2, . . .}. An inductive definition of a function fwith domain X consists of three parts:

    Basis step A few initial values f (a), f (a+1), . . . , f (a+k 1) are specified.Equations that specify such initial values are initial conditions.

    Recursive step A formula to compute f (n) from the k preceding functionalvalues f (n1), f (n2), . . . , f (nk) is made. Such a formula is a recurrencerelation (or recursive formula).

    Terminal step Only values thus obtained are valid functional values. (Forconvenience, we drop this clause from the recursive definition.)

    In a recursive definition of f , f (n) may be defined using the values f (k), wherek = n, so not all recursively defined functions can be defined inductively; see Exer-cises 2531.

    Thus, the recursive definition of f consists of a finite number of initial conditionsand a recurrence relation.

    Recursion can be employed to find the minimum and maximum of threeor more real numbers. For instance, min{w, x, y, z} = min{w, {min{x,min{y, z}}}};max{w, x, y, z} can be evaluated similarly. For example,

    min{23,5,6,47,31} = min{23,min{5,min{6,min{47,31}}}} = 6and

    max{23,5,6,47,31} = max{23,max{5,max{6,max{47,31}}}} = 47

    The next three examples illustrate the recursive definition.

  • 28 CHAPTER 1 Fundamentals

    EXAMPLE 1.17 Define recursively the factorial function f .

    SOLUTION

    Recall that the factorial function f is defined by f (n) = n!, where f (0) = 1. Sincen! = n(n 1)!, it can be defined recursively as follows:

    f (0) = 1 initial conditionf (n) = n f (n 1), n 1 recurrence relation

    Suppose we would like to compute f (3) recursively. We must continue to applythe recurrence relation until the initial condition is reached, as shown below:

    Since f (0) = 1,1 is substituted for f (0) in equation (1.8) and f (1) is computed:f (1) = 1 f (0) = 1 1 = 1. This value is substituted for f (1) in equation (1.7) andf (2) is computed: f (2) = 2 f (1) = 2 1 = 2. This value is now returned to equa-tion (1.6) to compute f (3): f (3) = 3 f (2) = 3 2 = 6, as expected.

    We now return to the handshake problem.

    EXAMPLE 1.18 (The handshake problem) There are n guests at a party. Each person shakes handswith everybody else exactly once. Define recursively the number of handshakes h(n)made.

    SOLUTION

    Clearly, h(1) = 0, so let n 2. Let x be one of the guests. The number of handshakesmade by the remaining n 1 guests among themselves, by definition, is h(n 1).Now person x shakes hands with each of these n 1 guests, yielding n 1 hand-shakes. So the total number of handshakes made equals h(n 1) + (n 1), wheren 2.

    Thus, h(n) can be defined recursively as follows:

    h(1) = 0 initial conditionh(n) = h(n 1) + (n 1), n 2 recurrence relation

  • 1.4 Recursion 29

    EXAMPLE 1.19 (Tower of Brahma) According to a legend, at the beginning of creation, Godstacked 64 golden disks on one of three diamond pegs on a brass platform in thetemple of Brahma at Benares, India (see Figure 1.10). The priests on duty wereasked to move the disks from peg X to peg Z, using Y as an auxiliary peg, under thefollowing conditions:

    Figure 1.10

    Only one disk can be moved at a time. No disk can be placed on the top of a smaller disk.

    The priests were told the world would end when the job was completed.Suppose there are n disks on peg X. Let bn denote the number of moves needed

    to move them from peg X to peg Z, using peg Y as an intermediary. Define bn recur-sively.

    SOLUTION

    Clearly b1 = 1. Assume n 2. Consider the top n 1 disks at peg X. By definition,it takes bn1 moves to transfer them from X to Y using Z as an auxiliary. That leavesthe largest disk at peg X; it takes one move to transfer it from X to Z. See Figure 1.11.

    Figure 1.11

    A puzzle based on the Tower of Brahma was marketed by the French mathematician Franois-Edouard-Anatole Lucas in 1883 under the name Tower of Hanoi.

    Benares is now known as Varanasi.

  • 30 CHAPTER 1 Fundamentals

    Now the n 1 disks at Y can be moved from Y to Z using X as an intermediaryin bn1 moves, so the total number of moves needed is bn1 +1+bn1 = 2bn1 +1.Thus bn can be defined recursively as follows:

    bn ={

    1 if n = 1 initial condition2bn1 + 1 if n 2 recurrence relation

    For example,

    b4 = 2b3 + 1 = 2[2b2 + 1] + 1= 4b2 + 2 + 1 = 4[2b1 + 1] + 2 + 1= 8b1 + 4 + 2 + 1 = 8(1) + 4 + 2 + 1 = 15,

    so it takes 15 moves to transfer 4 disks from X to Z.Notice that the recursive definition of a function f does not provide us with

    an explicit formula for f (n) but establishes a systematic procedure for finding it.The iterative method of finding a formula for f (n) involves two steps: 1) apply therecurrence formula iteratively and look for a pattern to predict an explicit formula;2) use induction to prove that the formula does indeed hold for every possible valueof the integer n.

    The following example illustrates this method.

    EXAMPLE 1.20 Solve the recurrence relation in Example 1.18.

    SOLUTION

    Using iteration, we have:

    h(n) = h(n 1) + (n 1)= h(n 2) + (n 2) + (n 1)= h(n 3) + (n 3) + (n 2) + (n 1)...

    = h(1) + 1 + 2 + 3 + + (n 2) + (n 1)= 0 + 1 + 2 + 3 + + (n 1)= n(n 1)

    2, by Example 1.11

    (We can verify this using induction.)

  • 1.4 Recursion 31

    E X E R C I S E S 1.4

    In Exercises 16, compute the first four terms of the se