>) Universities Press —— MATHEMATICS. Mathematical Marvels FIRST STEPS IN NUMBER THEORY A Primer on DIVISIBILITY Seooecocooooooec Shailesh Shirali Mathematical Marvels FIRST STEPS IN NUMBER THEORY A Primer on DIVISIBILITY Shailesh Shirali Universities Press Contents Preface 1 Introduction 1.1 What Is Number Theory? 1.2 Terms And Symbols, 2 Congruences 2.1 Introduction 2.2 Odd And Even Numbers 2.3 The Remainder Symbol 2.4 Other Divisors 2.5 The Congruence Symbol 2.6 Using Congruences 2.7 A Test For Divisibility By 13 2.8 Using Negative Remainders 3 The Elementary Cases 3.1 Introduction 3.2 Divisibility By 2 3.3 Divisibility By 5 34 Divisibility By 4 3.5 A Generalization 4 The Remaining Cases 4.1 Introduction 4.2 Divisibility By 9 ibility By 11 ; General Results 4.5 Divisibility By 101 4.6 Divisibility By 7 And 13 4,7 Divisibility By 27 And 37 48 Other Divisors 4.9 Concluding Remarks 5 A Different Approach 5.1 Introduction 4 FIRST STEPS IN NUMBER THEORY: A PRIMER ON DIVISIBILITY 5.2 Divisibility By 7 533 Another Formulation 54 Searching For New Rules 5.5 Divisibility By 17 5.6 Divisibility By 53 5.7 Divisibility By 11 6 Non-Decimal Bases 6.1 Introduction 6.2 Divisibility By 2 6.3 When d Divides b— 1 6.4-When d Divides b+ 1 6.5 The Remaining Cases 6.6 Concluding Remarks 7 Special Topics 7.1 Appetizers 7.2 GCDs 73 The Two Jug Problem 7.4 Wilson's Theorem 75 Fermat's “Little” Theorem 7.6 The Divisor Function 1.7 The Factorial Numbers 7.8 Two Applications 7.9 Pythagorean Triples 7.10 Pell’s Equation 7.11 Automorphic Numbers 7.12 Consecutive Integers 7.13 Sums of Reciprocals 7.14 Primality Testing 7.15 Polynomials 8 Miscellaneous Problems 8.1 Problems 8.2 Solutions 8.3 The Last Word Further Reading Mathematical Olympiads Appendix C: Solutions Index Preface You have no doubt encountered the following statement: A number is divisible by 9 if and only if the sum of its digits is divisible by 9. This statement gives a test for divisibility by 9. In this book, you will read about other such tests and about the rich theory behind them. En route, you will encounter a subject called Number Theory. To study this book, all you really need is familiarity with elementary arithmetic and algebra (addition and subtraction of algebraic expressions, the laws of exponents, the idea of prime factorization of an integer, the notion of relative primeness of two integers, etc); in short, material which would normally be covered in classes 7-9 in most countries. It is amazing how far one can go from these simple beginnings! You must be familiar with the tests of divisibility by divisors such as 2, 3, 4, 5, 6, 8, 9, 10 and 11. Of these, the test for divisibility by 2 was probably the one you first came across, followed by the one for divisibility by 10, then the one for divisibility by 5, ...; and last of all, the one for divisibility by 11. Perhaps it struck you as strange that there seemed to be no tests for divisibility by 7 and 13, The logic behind the tests may also have been a source of puzzlement; for instance, the test for divisibility by 11. In this book, we shall study such tests. We shall also devise tests for divisibility by numbers such as 7, 13, 17, 19, 23, ..., and explain why the tests for divisibility by 2, 3, 4, 5, ..., 11 are so simple, whereas those for divisibility by 7, 13, 17, 19, ..., are relatively more complicated. Except for Chapter 6, we shall be working throughout in the base-10 system (with place values based on the powers of 10; so when we say ‘453’, what we refer to is the number (4 x 100) +(5 x 10) +(3x1)). There are other number systems— the binary system, based on the powers of 2, the ‘enary system, based on powers of 3, and so on. In Chapter 6, we explore tests of divisibility for numbers expressed in other bases. ‘vil FIRST STEPS IN NUMBER THEORY: A PRIMER ON DIVISIBILITY Chapters 7 and 8 are more advanced than the earlier chapters and meant to be studied by those with a much deeper interest in the subject. However, they are quite self-contained and can be understood without having to refer to other textbooks. The chapter contents are briefly described below. [) sntroduetion This chapter is, as its title indicates, an introductory one. The first section imparts a sense of what number theory is about. Brief bits of history are included, and also definitions of the unfamiliar terms used in the book. Congruences ‘This introduces an extremely important and useful concept in elementary number theory—that of congruences. LB) the Elementary Cases Here, we study the tests for divsiblity by the numbers 2, 4, 8, 16, ..., 5, 25, 125, ..., and by the products of these numbers. [4] The Remaining Cases : In this chapter, we study tests for divisibility by odd numbers which are not powers of 5; that is, by numbers such as 3, 9, 11, 13, 17, 19, ... [5] 4 Different Approach ‘This chapter introduces a very different approach to the tests of divisiblity; it is more iterative in nature. [G] tests OF Divisibitity In Other Bases Here, we study extensions of the familiar tests to the cases where the numbers are expressed in non-decimal bases. Special Topics - In this chapter, several “bread-and-butter” topics of eleme: tary number theory are studied, though not in a textbook-ish PREFACE ix manner. A lot of interesting material is presented and several problems are discussed, along with some curious applications. Miscellaneous Problems This contains just what the title suggests— problems, problems, and more problems; all woven in some way around the theme of divisibility. Many of the problems have their origins in the Olympiads. Exercises will be found in plenty, scattered through the book. These are meant to be done! As has wisely been said, mathematics is not a spectator sport—one learns and begins to appreciate the subject only after starting to “do” it. This may be true of any subject, but nowhere more so than in the case of Mathematics. At the end of the book solutions are given in full. These should be consulted only when all else fails! Acknowledgements The author gratefully acknowledges the help received from Dr ‘A Kumaraswamy and Mr V Sundararaman, with regard to the computer software (I4TX) and the PCs used in typesetting this book; the feedback provided by Professor Phoolan Prasad, Dr Jayant Kirtane and Shri P K Srinivasan on the content and style of the book; and the support provided by his wife Padmapriya and by his colleagues and friends Dr Radhika Herzberger and Professor Hans Herzberger. He also thanks Universities Press for the support he has received from them. Dedication 1 dedicate this book to my parents Shri Ashok R Shirali and ‘Smt Lata A Shirali. Chapter 1 Introduction 1.1 What Is Number Theory? The study of divisibility tests offers an excellent introduction to the subject called Number Theory, also sometimes known as the “higher arithmetic”. We start this chapter by giving you an idea of what this subject is all about. Listed below are some topics that belong to number theory. Alongside each topic are listed some typical problems in that particular topic. ‘The prime number sequence A prime number p is one whose only positive divisors are 1 and p. Here is the sequence of prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, .... Many facts are known about the primes, for instance, te. ‘« The number of primes is inf ‘« If nis a positive integer such that 2" ~1 is prime, then n is prime. Example 2” — 1 = 127 is prime, and so is 7. ‘« Every prime that is 1 more than a multiple of 4 can be written as a sum of two squares, and primes that are 1 less than a multiple of 4 cannot be written in this form. Example The primes 29 and 73, both of which are 1 more than some multiple of 4 (29 = 1+4-7, 73 = 144-18), can be written in this form: 29=57+27, 73 =87 +37. You can verify for yourself that the primes 11, 19 and 71 cannot be written as sums of two squares. * This was known to the Greeks. 2 FIRST STEPS IN NUMBER THEORY: A PRIMER ON DIVISIBILITY Patterns in divisibility Here are some sample results: # A number is divisible by 3 if and only if the sum of its digits is divisible by 3. Example 252 is divisible by 3, and so is 2+5+ 257 is not divisible by 3, and neither is 2+5+7= 14. Let n be any integer, and let N =n? +1. Then each odd divisor of N is of the form a? +6? for some integers a, b. 9; but Example Let n= 13; then N = 170, and the odd divisors of NV are 5, 17 and 85. Observe that 5 and 85 = 9? +22, ‘* Let p be a prime number such that 2° — 1 is not prime. Then each divisor of 2°—1 is 1 more than a multiple of 2p. Example 11 is prime, but 2!" ~ 1 = 2047 is not prime. The proper divisors of 2047 are 23 and 89 (2047 = 23 x 89). Note that 1, 23, 89 and 2047 are all of the form 1 plus a multiple of 22. * Let K be a power of 2 such that 2* +1 is nor a prime number. ‘Then each prime factor of 2 +1 is of the form ak +1 for some integer a. Example It is known that 2°? +1 is not prime; this was first discovered by Euler, who showed that 641 is one of its prime factors, Observe that 641 = 20-32 +1, that is, 641 is of the form 32a +1, with a = 20. Solutions of equation: ems: ‘« Find all pairs of positive integers m,n such that 2" and 3° differ by 1 (e.g, 2 and 3? differ by 1). ‘« Find an integer lying between 0 and 1000 that leaves a remain- der of 1 when divided by 7, a remainder of 2 when divided by 11, and a remainder of 3 when divided by 13, integers Here are a few sample prob- 37 ‘= Can positive integers a,b,c be found such that a® + 5° Functions defined on the integers Here are two functions that have been studied very intensively by number theorists: CHAPTER |, INTRODUCTION. 3 © For z > 0, let f(z) be the number of prime numbers less than or equal to 2; thus (10) = 4, f(20) = 8, .... This function is of great interest to number theorists. A typical question: Can (1000000) be calculated without having to list all the primes less than 1000000? «Let p(n) be the number of ways that the positive integer n can be written as a sum of positive integers. Thus, p(4) = 5, because 4 can be written as a sum of positive integers in the following five ways: 4, S41, 242, 24141, 1414141, whereas p(5) = 7, because 5 can be written as a sum of positive integers in the following seven ways: 5, 441, 342, 34141, 24241, Qt1+141, 141414141 This is the partition function. There is a wonderful formula found by Ramanujan and Hardy that allows us to calculate the values of p(n) with ease. As n increases, p(n) grows very rapidly, as the following display shows: (50) = 204226, p(100) = 190569292, (200) = 3972999029388, Number theory has a glorious history behind it. The Greeks were deeply interested in it, perhaps because of the natural elegance and simplicity of the subject, but also for philosophic reasons: to them the universe was “made up” of numbers. They investigated the relationship between numbers and beauty; for instance, the appeal of certain shapes in art (e.g., the golden rectangle) and chords in music. They even constructed the musical scale: Do—Re—Me-Fa~So—La—Te—Do, (in the Indian system: Sa—Re~Ga—Ma—Pa—Da—Ni—Sa) ‘on a numerical basis. (Actually, so did the Indians.) There are two particularly beautiful theorems of elementary number theory dating from Greek times that are stated in Euclid’s ancient text, The Elements: