MEI Conference, 2009 Brush Up On your Number Theory Oscar Gregan noel.gregan@virgin.net Fermat’s Factorising Method Aim: To factorise a large integer, N, which is the product of two large integers a and b only. [We ignore the trivial case of factors 1 and N]. Obviously • N is an odd number. • a and b are odd prime numbers. • N = ab It is less obvious that we can write N = x2 – y2 = (x ‐ y) (x + y) where x and y are positive integers. The above follows from the identity = ab. As a and b are both odd, & will both be integers. Procedure: Rearranging N = x2 – y2 , we get x2 ‐ N = y2 . Calculate and round up. Let this number = k. [k2 – N > 0. We search for k. ] Work out k2 ‐ N = q (k + 1)2 ‐ N = q (k + 2)2 ‐ N = q ……………………….. (k + n)2 ‐ N = q . This is continued until q is a square number. ⇒ q = y2 Then, N = (k + n + y) (k + n ‐ y), the product of two integers. Without a spreadsheet, verifying that “q “ is really a square number can be speeded up by only checking those numbers ending in 00,01,04,09,16,21,24,25,29,36,41, 44,49,56,61,64,69,76,81, 84,89,96. [22 out of 100 numbers] Example: Write √ as a product of two prime factors. = 45029.51.. → 45030 (k + …) 45030 45031 45032 45033 45034 45035 45036 45037 45038 45039 45040 45041 2 (k+…) ‐ N (= q = y2) 49619 139680 229743 319808 409875 499944 590015 680088 770163 860240 950319 1040400 √q = y 222.7532267 373.7378761 479.3151364 565.5156939 640.2148077 707.0671821 768.1243389 824.6744812 877.5893117 927.4912399 974.8430643 1020 * * * * * * * * * * * 46061 * * * * * * * * * * * and * * * * * * * * * * * 44021 (45041 + 1020)(45041‐1020) =2027651281 Limitations of method The advantage of this method is that it does not require knowledge of the all the primes less or a related number of divisions. In the above example 12 steps were needed, as than compared to the 4850 divisions of odd primes under 44021. While the procedure will eventually find two factors or show that N is prime, it can be impractically long. We would hope that + k, where k < 100 (say), would generate a factor, i.e. the factors are nearly the same magnitude. The method is practical when a and b have similar magnitudes. • • • • Congruence a is congruent to b (modulo n) <=> n|(a – b) or a÷n and b÷n have same remainder. For example: 1 = 8 = 15 = 22 = ‐ 6 (mod7). {...... – 6, 1, 8, 15, 22 .....} is an example of a residue class mod 7. Properties: o If a = b (mod m) and if a = b (mod n) then a = b (mod mn) if gcd (m, n = 1). e.g. 3 = 18 (mod 3) and 3 =18 (mod 5) => 3 =18 (mod 15). o If ca = cb (mod m) then a = b (mod m/d) where d is gcd(c, m) o It follows from above that if ca = cb (mod m) then a = b (mod m) when gcd(c, m) = 1. Solving linear congruences i.e. equations of the form : ax = b (mod n) o Congruence has solutions if, and only if, gcd (a, n) divides b. o When gcd (a, n) = 1, the congruence has a unique solution. o If gcd (a, n) = d and d | b, then the congruence has d solutions. The solutions are found by finding the unique solution to x = (mod ). • Strategy for solving the linear congruence ax = b (mod n): 1. Verify that gcd (a, n) divides b. If it does not then the congruence has no solutions. 2. Cancel any common divisors of all three of a, b and n. The resulting coefficients can then be changed by using any of the following rules: 3. Cancel any common divisor of the coefficients 4. Replace any coefficient by any congruent number. 5. Multiply through the congruence by any number which is relatively prime to the modulus. Examples: Solve the following linear congruences: 1) 8 x = 12 (mod 60) Solution: 2x = 3 (mod 15) [gcd (8, 60) = 4 => 4 solutions] => 16x = 24 (mod15) => x = 9(mod15) => x = 9, 24, 39, 54 (mod 60). 2) 21x = 35 (mod 47) Solution: 3x = 5 (mod 47) => 48x = 80 (mod 47) => x = 33(mod 47). 3) 6x = 5 (mod 41) Solution: 42x = 35 (mod 41) => x = 35(mod 41). Fermat’s Little Theorem [FLT] o If p is prime and gcd(a, p) = 1 , then a p – 1 = 1(mod p). Example: 47‐ 1 – 1 = 0 (mod 7) i.e. FLT indicates that 4 7‐ 1 – 1 should be divisible by 7. 47‐ 1 – 1 = 4095 and 4095 ÷ 7 = 585. Exercises: 1. Show 3737 + 2 is divisible by 13 i. By using congruence properties ii. By using FLT 2. Find the remainder when 1111 is divided by i. 7 ii. 17 iii. 19 3. Use FLT to show that: i. 350 + 550 is divisible by 17. ii. 2100 + 3100 is divisible by 97. The Chinese Remainder Theorem In the first century the Chinese mathematician Sun‐ Tsu proposed the following problem: Find a number which leaves a remainder 2 when divided by 3; a remainder 3 when divided by 5 and a remainder 2 when divided by 7. Expressing the problem in congruences we get x = 2(mod 3); x = 3(mod 5); x = 2(mod 7) x = 2(mod 3) => x = 2, 5, 8, 11, 14, 17, 20, 23, 26 , 29, .............. x = 3(mod 5) => x = 3, 8, 13, 18, 23, 28, .................. x = 2(mod 7) => x = 2, 9, 16, 23, 30, .............. So x = 23 is a solution to Sun‐TSU’s problem. If we continued the above sequences we would find that the next number common to all three lists is 128. Now 128 = 23 + 105 and 105 3 5 7. So x 23 mod 105 . This is an example of the Chinese Remainder Theorem. An Algebraic approach: • x = 2(mod 3) => x = 3r + 2 where r is a positive integer. • x = 3(mod 5) => 3r + 2 = 3(mod 5) => 3r = 1(mod 5) . Testing r = 0, 1, 2, 3, 4 gives solution r = 2(mod 5) => r = 5s +2 => x = 3(5s +2) + 2 => x = 15s + 8 . • x = 2(mod 7) => 15s + 8 = 2 (mod 7) . => s +1 = 2 (mod 7) => S = 1(mod 7) => s = 7t + 1 => x = 15(7t + 1) + 8 => x = 105t + 23 => x = 23 (mod105) [same as above] Chinese Remainder Theorem: The system of linear congruences x = a(mod n1); x = b(mod n2); x = c(mod n3); ....... ; x = k (mod nr) has a simultaneous solution which is unique mod(n 1 n2 n3 .. n) provided gcd(a, b )= gcd(b, c) =.... = gcd(c, k) = 1 Algorithm: x = 2(mod 3); x = 3(mod 5); x = 2(mod 7) coefficients: a = 2, b = 3, c = 2 n3 = 7 moduli: n1 = 3, n2 = 5, N = 3 × 5 × 7 = 105 N1 = 5 × 7= 35 N2 = 3 × 7 =21 N3 = 3 × 5 = 15. => x1 = 2 N1 x = 1(mod 3) => 35x = 1(mod 3) => 2x = 4 (mod 3) => x = 2(mod 3) =>x2 = 1 N2x = 1(mod 5) => 21x = 1 (mod 5) => x = 1(mod 5) => x3 =1 N3x = 1(mod 7) => 15x = 1 (mod 7) => x = 1 (mod 7) X0 = a N1 x1 + b N2 x2 + cN3x3 = 2 × 35 × 2 + 3× 21 × 1 + 2 × 15 × 1 = 233(mod105) = 23(mod105). PRIME, CONGRUENCE PROBLEMS [Open University] [Open University] [Open University] Pythagorean Triples and Sums of Squares • • x2 + y2 = z2 is an example of a Diophantine Equation: an equation which is to be solved within the set of integers, invariably positive integers. We concern ourselves with the cases where (x, y, z) is a primitive triple i.e. gcd(x, y) = 1 => gcd (x, y, z) = 1. All of x, y and z cannot be odd. One of x, y must be odd and one must be even. Useful is the observation that a square number = 0 or 1(mod 4). => z will be an odd number if (x, y, z) is primitive. The primitive Pythagorean triples are always of the form ( 2mn, m2 – n2, m2 + n2). Gcd (m, n) = 1, m > n and m and n have opposite parity (odd/even). => 4| 2mn. A Pythagorean triple can include two prime numbers. Here (x, y, z) = [ , p, ] • One of (x, y, z) is always divisible by 3 and by 4 and by 5. • • Examples: 1. Find all primitive Pythagorean triples (72, y, z) Solution : 2mn =72 => m = 36, n = 1 => (72, 1295, 1297) = (x, y, z). Or 2mn =72 => m = 9 , n = 4 => (72, 65, 97) = (x, y, z). Or 2mn =72 => m = 12 , n = 3 => (72, 135, 153) = (x, y, z). Note: 2mn =72 => m = 12 , n = 2 => (72, 320, 328) = (x, y, z). This is a Pythagorean triple but not a primitive Pythagorean triple. Exercises: 1. Find all Pythagorean triples in which the three sides are in arithmetic progression. 2. Find all Pythagorean triples for which the area of the associated right angled triangle has the same magnitude as the perimeter. Sums of Squares: 2009 = X2 + Y2. • • • Some numbers can be expressed as the sum of two squares. Some numbers can be expressed as the sum of three squares. Every positive integer can be expressed as the sum of four squares. Important identity: (a2 + b2)(c2 + d2) = (ac + bd)2 + (ad – bc)2. From above identity: if M can be written as the sum of two squares and N can be written as the sum of two squares then their product, MN can also be written as the sum of two squares. • An odd prime number, p, can be expressed as the sum of two squares in a unique way if p=1(mod 4) but not if p =3(mod 4). [ All prime numbers take the form 4k + 1 or 4k +3]. So, for example, 5 = 12 + 22; 13 = 32 + 22; 17 = 42 + 12..... but 3, 7, 11, 19 .... can’t be done. • A positive integer can be expressed as a sum of 2 squares if, and only if, its prime divisors of the form 4k + 3 occur as even powers. So 45 = 32 × 5 = 32(22 + 12) = 62 + 32 but 15 = 3×5 can’t be done. • A positive integer, N, can always be written as the sum of three terms unless N can be written as 4n(8m + 7). • Writing a prime = 1 (mod 4) as the sum of two squares: While there are algorithms to find x2 + y2, for practical purposes it is better to use “trial and improvement” / inspection for medium sizes primes. Examples : 1. Write each of the numbers 245, 260 and 245 × 260 as the sum of two squares. Solution: 245 = (5) × (72) = (22 + 12)(72 + 02) = (2×7 + 0)2 + (0 – 7)2 = 142 + 72. 2 2 2 2 2 260 = 2 × 5 × 13 = 2 (2 + 1 )( 2 + 32) = 22[(4 + 3)2 + (6 – 2)2] 2 2 2 2 = 2 [7 + 4 ] = 14 + 82. 245 × 260 = [142 + 72][ 142 + 82] = [(196 + 56)2 + (112 – 98)] = 2522 + 142. 2. Consider the three numbers 368, 370 and 372. a. For each one decide whether or not : i. It can be expressed as a sum of two squares giving reasons ii. It can be expressed as a sum of three squares giving reasons. b. For any that can be written as the sum of two squares , find the two square numbers. [Open University] 4 Solution: 368 = 2 × 23; 370 = 2 × 5 × 37; 372 = 2 × 3 × 31 (i) 368: 23 = 3 (mod 4) => No ; 370: 5 = 37 = 1(mod4) => Yes; 372: 3 = 31 (mod 4) => No ; (ii) 368 = 24 × (8 × 2 + 7) => No; 370 = 2 × 5 × 37 = 2 × (185) = 21(8 ×23 + 1) => Yes; 372 = 2 × 93 = 2(8 × 11 + 5) => Yes; (iii) 370 = (32 + 12)(62 + 12) = (18 + 1)2 + (3 ‐ 6)2 = 192 + 32. Pythagorean Triples and Sums of Squares: Problems. [Open University] [Open University] 3. Write 2009 as the sum of two squares. Brush up on your Number Theory: Mersenne primes and perfect numbers. Perfect Numbers: Charles Clarke’s Bloomer: http://news.bbc.co.uk/1/hi/programmes/more_or_less/7847143.stm http://www.mersenne.org/ Divisibility tests: o At a glance we can tell if 2, 5 & 10 are factors of a bigger integer o 4&8?: o 3&9?: o 11?: o 7??: o Proof of these divisibility tests Why isn’t 1 a prime? After all 1 divides itself and 1! The Fundamental Theorem of Arithmetic and the prime decomposition of divisors. where a, b, c..... are integers ≥ 0. N = (p1)a ( p2)b (p3)c..(pr)r τ [tau or taw !] , σ and multiplicative functions: o τ(n) = number of factors of n, e.g. τ(9) = 3. [ 1, 3 & 9] o σ(n) = sum of all the factors of n, e.g. σ(9) = 1+ 3+ 9 = 13. Multiplicative functions: f [(p1)a ( p2)b (p3)c..(pr)r] =f (p1)a f( p2)b f(p3)c.. f(pr)r. τ & σ can be proved to be multiplicative functions . = ? So if N = (p1)a ( p2)b (p3)c…..(pr)r then τ [(p1)a ( p2)b (p3)c..(pr)r] a b c r = ?. and σ (p1) ( p2) (p3) ..(pr) If p is a prime number then τ(p) = ? σ(p) = ? σ(n) (where n is a perfect number) = Exercises: 1. Find τ (360) & σ(360). 2. If p is a prime number > 3 , find τ(2p3), σ(3p) & σ(6p2). 3. Find all the numbers less than 100 that have exactly 10 factors. 4. Find the smallest number that has exactly 24 factors. ? Mersenne Numbers and Perfect Numbers 1. Mp = 2P – 1 is a Mersenne number. When is N prime? P is prime is a necessary but not a sufficient condition. Examples of Mersenne primes are M2 = 3, M3 = 7 M5 = 31, M7 = 127 ........ Why is M11 significant ? • If p(>3) and 2p + 1 are both primes and if p = 3 (mod 4) then Mp is divisible by 2p +1. • 2. A perfect Number σ(n) = 2n. e.g. σ(6) =1+2+3+6 =12. So 6 is a perfect number. 3. Every Mersenne Prime generates a perfect number. Every known perfect number is even. 4. The Formula that Charles Clarke forgot N = (2P ­ 1)(2P – 1), when 2P – 1 is prime, is always a perfect number and every even perfect number takes that form. Proof of N = (2P ­ 1)(2P – 1), when 2P – 1 is prime, is always a perfect number : Let N = (2P ‐ 1)(2P – 1) σ(N) = σ[(2P ‐ 1)(2P – 1)] = σ(2P ‐ 1)σ(2P – 1) as σ is a multiplicative function. σ(2P ‐ 1) = 1 +21 +22 + ..... +2P ‐ 1 , a geometric series. σ(2P ‐ 1) = 2P – 1. Since 2P – 1 is a prime number, σ (2P – 1) = 2P – 1+1 = 2P. Hence σ(N) = σ(2P ‐ 1)σ(2P – 1) = (2P – 1)× 2P = 2×(2P – 1)× 2P‐1 = 2×N which is a definition of a perfect number. As there are 47 known Mersenne primes there are 47 associated perfect numbers contrary to Charles Clarke’s contention. 5. Fn = + 1(Fermat Numbers): Only the first five of these numbers F0, F1....F4 are known to be prime which may be what Charles Clarke intended to mention. Multiplicative functions: Problems [Open University] [Open University] [Open University] [Open University] Brush up on your Number Theory Miscellaneous Problems Sheet 1. Design a spreadsheet to apply Fermat’s factorising method and use the sheet to factorise a) 211 – 1 b) 340663 c) 2027651281 2. Using prime decomposition a) Find all the numbers less than 150 that have exactly 12 factors b) Find the smallest number that has exactly 24 factors. c) Find how many zeros there are after the last non‐zero digit in 50! 3. Prove by induction that X n – 1 = (x ‐1) (x n‐1 + x n‐2 + ... + x 2 + x + 1) [Let n ≥ 2. ] 4. 2P – 1 is a prime number. Show a) P cannot be an even number b) P cannot be an odd composite number. 5. On a recent Edexcel GCSE specimen paper: “Show that the square of any number in the sequence 1, 4, 7, 10, 13.... is also in that sequence.” 6. Show that 3, 5, 7 are the only set of prime triplets 7. Show that the sum of any two twin primes (e.g. 5 & 7, 17 & 19...) is always divisible by 12. 8. If p is a prime number and 3p +1 is a square number then show that p = 5 only. 9. 34! = 295 232 799 cd9 604 140 847 618 609 643 5ab 000 000. Determine the digits a, b, c, d. [ BMO1, 2002]