Chapter 1 Numbers and their divisors 1.1 Some number theoretic functions Theorem 1.1 (Fundamental Theorem of Arithmetic). Every positive integer > 1 is uniquely the product of distinct prime powers: n = k i=1 p a i i. Theorem 1.2 (Bertrand s Hypothesis). Let n > 1 be an integer. There is a prime number p such that n < p < 2n. Here are three important number theoretic functions. 1. The number of divisors function: d(n) := {d N : d n}. 2. The sum of divisors function: σ(n) := d n d. 3. Euler ϕ-function: ϕ(n) := {k Z : 1 k n and gcd(k, n) = 1}. Each of these functions is multiplicative, i.e., f(mn) = f(m)f(n) if gcd(m, n) = 1. They are therefore determined by their values at the prime powers. 1. d(p a ) = 1 + a; 2. σ(p a ) = 1 + p + + p a = pa+1 1 3. ϕ(p a ) = p a p a 1 = p a (1 1 p p 1 ; ). 101
102 CHAPTER 1. NUMBERS AND THEIR DIVISORS Example 1.1. Find the smallest integer with exactly 28 divisors. Solution. If N = p a 1 1 p a 2 2 p a k k for distinct primes p 1, p 2,...,p k, then (1 + a 1 )(1 + a 2 ) (1 + a k ) = 28 = 2 2 7. The only possibilities are (i) k = 2, a 1 = 3, a 2 = 6, N = p 3 1 p6 2 (a product of 9 primes); (ii) k = 3, a 1 = a 2 = 1, a 3 = 6, N = p 1 p 2 p 6 3 (a product of 8 primes). From these it is clear that the smallest N is 2 6 3 5 = 960. Example 1.2. A minimum security prison contains 100 cells with one prisoner in each. The athletic young warden was ordered to free a certain number of these prisoners at his discretion, and this is how he did it. First he walked along the row of cells opening every door. Starting at the beginning again, he shut every second door. During his third walk, starting at the beginning, he stopped at every third door: if it was open he shut it, if it was shut he opened it. On his fourth walk he did the same, opening closed doors and closing open doors, except he did it for every fourth door. On his fifth walk he stopped at every fifth door, closing it if it was open and opening it if it was shut. And so on, until at last he had completed the full hundred walks. The prisoners in the open cells were freed. Which were the lucky cells? Solution. (1) The status (open or close) of cell n( 100) is reversed at the k-th walk if and only if k is a divisor of n. (2) Cell n is open at the end if and only if it has an odd number of divisors, i.e., n is a square. Therefore the lucky cells are cells k 2 for k 10.
1.2. PERFECT NUMBERS 103 1.2 Perfect numbers A number n is perfect if it is equal to the sum of all its proper divisors, including 1. Thus, 6 = 1 + 2 + 3, 28 = 1 + 2 + 4 + 7 + 14 are perfect numbers. Let σ(n) denote the sum of all positive divisors of n, including 1 and n. Note that a number n is perfect if σ(n) = 2n. Theorem 1.3 (Euclid). Let p be a prime number such that M p = 2 p 1 is prime. Then the number E P := 2 p 1 M p is perfect. Proof. If M p is prime, then the prime factors of E p are precisely These add up to 1, 2, 2 2,..., 2 p 1, M p, 2M p, 2 2 M p,..., 2 p 1 M p. (1 + 2 + 2 2 + + 2 p 1 )(1 + M p ) = (2 p 1) 2 p = 2E p, showing that E p is perfect. Theorem 1.4 (Euler). If n is an even perfect number, then n = 2 k 1 (2 k 1) for some integer k and M k = 2 k 1 is prime. Proof. Write n = 2 k 1 q, q odd. Since n is perfect, 2 k q = 2n = σ(n) = σ(2 k 1 )σ(q) = (2 k 1)σ(q). From this, σ(q) = q + q. Since σ(q) is an integer, 2 k 1 2k 1 must be a divisor of q. Indeed, we must have 2 k 1 = q, for otherwise q would have other positive divisors, which should enter into the sum σ(q). It follows that σ(q) = q + 1, and this means that q = 2 k 1 is a prime. Remark. It is not known if an odd perfect number exists. Example 1.3. Prove that a square integer cannot be a perfect number. Solution. Let N = (2 k Q) 2 for an odd number Q and an integer k 0. σ(n) = σ(2 2k Q 2 ) = σ(2 2k )σ(q 2 ). Note that (i) σ(2 2k ) = 1 + 2 + + 2 2k is odd, and (ii) σ(q 2 ) is also odd, because Q 2 has an odd number of divisors which are all odd. It follows that σ(n) is an odd number, and cannot be equal to 2N. N cannot be a perfect number.
104 CHAPTER 1. NUMBERS AND THEIR DIVISORS Exercise 1. Find all perfect numbers n for which both n 1 and n+1 are prime numbers. 2. Show that if the sum of all divisors of n is a prime, then the number of divisors of n is also prime. 3. (a) Show that k and k + 1 are always relatively prime. (b) From the numbers 1, 2,..., 2n, randomly select n+1 numbers. Show that two of them must be relatively prime. 4. Show that 1 + 1 + + 1 is never an integer for n 2. 2 3 n
Chapter 2 Floor and Ceiling For a real number x, we denote by x the greatest integer not exceeding x, (the floor of x), 1 x the least integer not smaller than x, (the ceiling of x). {x} := x [x] the fractional or decimal part of x. 2.1 Highest power of a prime dividing a factorial Theorem 2.1. The exponent of the highest power of a prime p dividing n! is n n n + + + p p 2 p 3 The exponent of the highest power of 2 dividing 18! is, counting the asterisks along the rows in the matrix below, 9 + 4 + 2 + 1 = 16. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Proof. Let n = (a k a k 1 a 1 a 0 ) p be the base p expansion of n. The exponent of the highest power of p dividing n! is the sum of the following numbers: 1 This is also denoted [x] in older books. 105
106 CHAPTER 2. FLOOR AND CEILING a k a k 1 a k 2 a 2 a 1 a k a k 1 a 3 a 2 a k a 4 a 3... a k a k 1 a k Let R(p; k) be the integer whose base p expansion consists of k digits each of which is 1. Clearly, R(p; k) = 1 p 1 (pk 1). Adding the numbers above along the diagonals, we have a k R(p;k) + a k 1 R(p; k 1) + + a 2 R(p;2) + a 1 R(p;1) =a k pk 1 p 1 + a k 1 pk 1 1 + + a 2 p2 1 p 1 p 1 + a1 p 1 p 1 + a0 1 1 p 1 = n (a k + a k 1 + + a 1 + a 0). p 1 Corollary 2.2. Let α(n) denote the number of ones in the binary expansion of n. The exponent of the highest power of 2 dividing n! is n α(n). Corollary 2.3 (Kummer s theorem). The exponent of the highest power of a prime p dividing the binomial coefficient ( ) a+b a is equal to the number of carries in performing the addition of a and b in base p.
2.1. HIGHEST POWER OF A PRIME DIVIDING A FACTORIAL 107 [ ] Example 2.1. Show that [nx] = x. n Solution. Write x = [x] + [y]+{y} [y], and [nx] n = [x] + [y] n for some y < n. Then [nx] = n[x] + n [ ] [y], with y < 1. This means that [nx] = [x]. n n n Example 2.2. Find all real numbers x such that x = x {x}. Solution. Write x = k + s for an integer k and 0 s < 1. We have ks = k + s; s = k. Note that 0 s < 1 if and only if k > 0. k+1 Thus, x = k + k = k2 for a positive integer k. k+1 k+1 Example 2.3. Find all integers n for which n divides n. Solution. Let n = m so that m n < m + 1. This means n = m 2 +k for 0 k 2m. Note that m divides n if and only if k = 0, m, or 2m. Thus, n = m 2, m(m + 1), or m(m + 2). Example 2.4. Find all real numbers x such that x 1 x = x. 1 x Answer. x [ 0, 2) 1 [2, 3). Solution. (i) x (ii) 1 x Writing x = 1 + t, we have = 1 + 1 t ; = 1+t t x 1 x = 1+ t t = 1 1 t. The problem is equivalent to finding t satisfying 1 t = 1 t. There are only two possibilities. (iii) t = 1 and 1 t = 1. With t = 1 +s for 0 s < 1, we have 1 = 1, and indeed 1 t 1+s t = 1. In this case, x = 1 + t satisfies 2 x < 3. (iv) t = 1 and t 1 = 1. With t = 1 + s for 0 s < 1, we have 1 = 1 = 1 satisfying 1 1 < 2. 2(1 s) > 1, s < 1. t 1+s 1 s 1 s 2 In this case, 1 t < 1 and 0 x < 1. 2 2
108 CHAPTER 2. FLOOR AND CEILING Exercise 1. Prove that n! cannot be a square. 2. How many zeros are there at the end of 1000!? 3. Find all prime numbers p for which there are exactly 2012 zeros at the end of p!. 4. Find all integers n for which n divides n. 5. Show that for any positive integers m and n, the integer (m + m2 1) n is odd. 6. Show that ( 3 + 1) 2n is divisible by 2 n+1. 7. For natural numbers n define f(n) := n n and g(n) := n. n Determine all n for which f(n) = g(n). 8. Determine all rational numbers x such that x{x} = x. 9. Show that there exist infinitely many irrational numbers x such that x{x} = x. 10. Determine all numbers x such that x{x} = x. Answer. The only real solution is x = 0. Solution. First consider the case when x is an integer. Here, {x} = 0 and the only solution is x = x = x{x} = x 0 = 0. If x is not an integer, write x = n+θ for an integer n and 0 < θ < 1. We require (n + θ)θ = n + 1. This simplifies into (θ + 1)(θ (n + 1)) = 0, θ = 1 or n + 1, contradicting 0 < θ < 1. There is no non-integer solution.
Chapter 3 Number Theory Problems 3.1 A number game of Lewis Carroll How would you get A from D? Take a secret number Multiply it by 3 Tell me if it is Do the corresponding routine Multiply by 3 Tell me if it is Do the corresponding routine Add 19 to the original number A and put an extra digit at the end Now add B and C Divide by 7 and get the quotient only Further divide by 7 and get the quotient only Tell me this and I shall give you back A even or odd even or odd B C D D your A odd routine: Add 5 or 9, then divide by 2, and then add 1. even routine: Subtract 2 or 6, then divide by 2, and then add 29 or 33 or 37. 109
110 CHAPTER 3. NUMBER THEORY PROBLEMS Solution. A can be obtained from D by (i) forming 4D 15, (ii) subtracting 3 if the first parity answer is even, and (iii) subtracting 2 if the second parity answer is even. Analysis. e and e are either 0 or 1. f and f are 1, 0, or 1. g is an integer between 0 and 9. The last two steps of dividing by 7 and keeping the quotients can be combined into one single step of dividing by 49. A 4k + 1 4k + 2 4k + 3 4k + 4 3A 12k + 3 12k + 6 12k + 9 12k + 12 Parity odd even odd even Routine 6k + 5 + 2e 6k + 35 6k + 8 + 2e 6k + 38 2e + 4f 2e + 4f 3 times 18k + 15 + 6e 18k + 105 18k + 24 + 6e 18 + 114 6e + 12f 6e + 4f Parity odd odd even even Routine B 9k + 11 9k + 56 9k + 43 9k + 89 +3e + 2e 3e + 2e +3e 2e 3e 2e +6f +4f +6f + 4f C 40k + 200 + g 40k + 210 + g 40k + 220 + g 40k + 230 + g B + C 49k + 211 + g 49k + 266 + g 49k + 263 + g 49k + 319 + g +3e + 2e 3e + 2e +3e 2e 3e 2e +6f +4f +6f + 4f lower bound 49k + 211 49k + 257 49k + 257 49k + 304 upper bound 49k + 225 49k + 283 49k + 279 49k + 318 D k + 4 k + 5 k + 5 k + 6 A 4D 15 4D 18 4D 17 4D 20
3.2. SOME DIGIT PROBLEMS 111 3.2 Some digit problems Example 3.1. The product of three consecutive even integers is 87 8. Find the (five) missing digits. Solution. (2k 2)(2k)(2k+2) = 8(k 3 k) = 87 8. Therefore, (k 1)(k)(k + 1) is a number of the form 10 + 1; k is around 215. The last digit must be 1 or 6. Since this number must be even, the last digit is 6. The number k can only be 217 or 222. The three even numbers are either 432, 434, 436 or 442, 444, 446. Now 432 434 436 = 81744768, 442 444 446 = 87526608. Only the first of these gives the correct product. The missing digits are 74476. Example 3.2. This is Problem E1 of the AMERICAN MATHEMATICAL MONTHLY: x 7 x x x x x x) x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Clearly, the last second digit of the quotient is 0. Let the divisor be the 3-digit number d. Consider the 3-digit number in the seventh line, which is a multiple of d. Its difference from the 4-digit number in the sixth line is a 2-digit number. This must be 9xx. This cannot be the same as the 3-digit number in the fifth line, since the difference between the 3-digit numbers in the fourth and fifth lines is a 3-digit number. Therefore, in the quotient, the digit after 7 is a larger one, which must be smaller than the first and the last digits, since these give 4-digit multiples of d. It follows that the quotient is 97809.
112 CHAPTER 3. NUMBER THEORY PROBLEMS Since 8d is a 3-digit number 9xx, the 4-digit number in the third and bottom lines is 9d = 10xx or 11xx. From this 8d must be 99x, and therefore 992 = 8 124. 9 7 8 0 9 1 2 4) 1 2 1 2 8 3 1 6 1 1 1 6 9 6 8 8 6 8 1 0 0 3 9 9 2 1 1 1 6 1 1 1 6
3.2. SOME DIGIT PROBLEMS 113 Exercise 1. Find all natural numbers whose squares (in base 10) are represented by odd digits only. 2. Find the three 3-digit numbers each of which is equal to the product of the sum of its digits by the sum of the squares of its digits. 3. Find all 4-digit numbers abcd such that 3 abcd = a + b + c + d. 4. Find a 4-digit number of the form aabb which is a square. Solution. A 4-digit number of the form aabb is divisible by 11. If it is a square, it must be (11c) 2 = 121 c 2 for some integer c = 3, 4,..., 9. Since b must be 1, 4, 6, or 9. Since a number congruent to 11, 66, 99 modulo 100 cannot be a square (consider their mod 4 values), the only possibility is b = 4. Correspondingly, c = 2 or 8. Now it is clear that only c = 8 works: 88 2 = 7744. 5. Use each digit 1, 2, 3, 4, 5, 6, 7, 8, 9 exactly once to form prime numbers whose sum is smallest possible. What if we also include the digit 0? 6. There are exactly four 3-digit numbers each equal to the sum of the cubes of its own digits. Three of them are 153, 371, and 407. What is the remaining one? 7. Find a number of the form aaabbbccc, which when increased by 1, gives a square. 8. Find the smallest 3-digit number N such that the three numbers obtained by cyclic permutations of its digits are in arithmetic progression. 9. The number (abbbb) 2 1 has 10 digits, all different. Find the number. 1 10. What three-digit squares have the following characteristics? (a) are palindromes. (b) are permutations of consecutive digits. 1 These are the only possibilities even if we consider more generally numbers consisting of two consecutive blocks of repeating digits, whose squares, to within ±1, contain all ten digits without repetition. 85555 2 1 = 7319658024; 97777 2 1 = 9560341728.
114 CHAPTER 3. NUMBER THEORY PROBLEMS (c) form reversal pairs. (d) are three permutations of the same digit set. (e) three of its permutations are prime. (f) the sum of the digits is 19. (g) is also a cube. (h) the central digit is perfect. (i) are composed of even digits. (j) the central digit is a nonzero cube.
3.2. SOME DIGIT PROBLEMS 115 Example 3.3. Show that the numbers 7744, 97970404, 997997004004, 9997999700040004,... are perfect squares. Solution. The numbers in the second sequence are the squares of 88, 9898, 998998, 99989998,.... The pattern 9 k 79 k 70 k 40 k 4 = (9 k 89 k 8) 2. It is easier to work backward: for k 1, we have (9 k 89 k 8) 2 = (9 k 8 10 k 1) 2 = ((10 k+1 2)(10 k+1 + 1)) 2 = (10 2k+2 10 k+1 2) 2 = 10 4k+4 2 10 3k+3 + 10 2k+2 4 10 2k+2 + 4 10 k+1 + 4 = 10 4k+4 2 10 3k+3 3 10 2k+2 + 4 10 k+1 + 4 = 10 4k+4 20 3k+3 30 2k+2 + 40 k+1 + 4 = 9 k 80 3k+3 30 2k+2 + 40 k 4 = 9 k 79 k 70 2k+1 + 40 k 4 = 9 k 79 k 70 k 40 k 4. Since 88 2 = 7744, this also holds for k = 0. Exercise 1. Show that the numbers 49, 4489, 444889, 44448889,... are all squares. 2. Show that the numbers 729, 71289, 7112889, 711128889,..., are perfect squares. 2 2 71 n 1 28 n 1 9 = 26 n 1 7 2.
116 CHAPTER 3. NUMBER THEORY PROBLEMS 3.3 Some number quickies 1. If a b 1 (mod 2) then a 2 + b 2 is not a square. Solution. a 2 + b 2 1 2 + 1 2 2 (mod 4) cannot be a square. 2. n 1 (mod 2) n 2 1 (mod 8). Solution. Let n = 2k + 1. n 2 = 4k(k + 1) + 1. Since one of k and k +1 is even, 4k(k +1) is divisible by 8, and n 2 1 (mod 8). 3. If n is not a prime, then 2 n 1 is not a prime. Solution. Let n = ab with a, b > 1. Then 2 n 1 = 2 ab 1 = (2 a ) b 1 is clearly divisible by 2 a 1 (which is greater than 1 and less than 2 n 1. The number 2 n 1 is not a prime. 4. If n has an odd divisor, then 2 n + 1 is not a prime. 5. Among five integers, there are always three with sum divisible by 3. 6. The sum of squares of five consecutive positive integers is not a square. Solution. (n 2) 2 + (n 1) 2 + n 2 + (n + 1) 2 + (n + 2) 2 = 5n 2 + 10 = 5(n 2 + 2). If this is a square, then n 2 + 2 is divisible by 5. This means that n 2 2 (mod 5), an impossibility. 7. Show that the product of four consecutive positive integers is not a square. Solution. n(n + 1)(n + 2)(n + 3) = n 4 + 6n 2 + 11n + 6n = (n 2 + 3n + 1) 2 1. Therefore, it cannot be a square. 8. Prove that for n a positive integer n 4 +2n 3 +2n 2 +2n+1 is never a perfect square. Solution. The given number is greater than n 4 + 2n 3 + n 2 = (n 2 + n) 2, but it is less than n 4 + 2n 3 + 3n 2 + 2n + 1 = (n 2 + n + 1) 2. Therefore, it cannot be a square. 9. If 9 a 2 + ab + b 2, then 3 a and 3 b. Solution. Since a 2 + ab + b 2 = (a b) 2 + 3ab is divisible by 9, (a b) 2 is divisible by 3, and therefore by 9. Therefore, 3ab is divisible by 9 and one of a and b is divisible by 3. Since a b is divisible by 3, it follows that the other one is also divisible by 3.
3.3. SOME NUMBER QUICKIES 117 10. Prove that the product of any n consecutive positive integers is divisible by n!. k(k+1) (k+n 1) Solution. = ( ) k+n 1 n! n is an integer, being the number of ways of choosing n objects from n + k 1 distinct ones.