TEXAS A&M UNIVERSITY Prime Factorization A History and Discussion Jason R. Prince April 4, 2011
Introduction In this paper we will discuss prime factorization, in particular we will look at some of the basic concepts involving prime factorization as well as proving one of the most important theorems in mathematics, The Fundamental Theorem of Arithmetic. Then we will look at some methods for factoring numbers into their prime factorizations. These topics are going to help show the fact that in general finding the prime factorization of a number is not necessarily an easy task. We can use Fermat s method if the number can be written as the difference of two perfect squares, and we can use Euler s method if the number can be written as the sum of two perfect squares in multiple different ways. Unfortunately though these methods will only work for these specific types of numbers. If we have any other type of number we may have a very difficult time factoring it. Background Before I can write a paper about prime factorization, I should probably define a few terms. First let us define divides, divisor, and multiple by saying that a divides b, written a b, if is an integer. Here a is a divisor of b, and b is a multiple of a. We use these terms to help us in defining the terms prime and composite by saying that an integer, p is prime if its only divisors are ±1 and ± p, and p 1. Similarly, we say any integer with more than these four divisors is called composite. Also the notion of two integers, m and n being relatively prime means that the only divisors that m and n both share are ±1. This can also be stated by using the greatest common divisor, which is the largest number that divides both m and n, by saying that the greatest common divisor is 1, written as (m, n) = 1. Page 1
We can take a look at a table of some of the prime numbers thanks to an algorithm created in the second century BC by a man named Eratosthenes. This algorithm is called the sieve of Eratosthenes, and is constructed by writing down all the integers from 1 to n, where n is the largest integer you want included in the table of primes. Then you start with 2, since by definition 1 is neither prime nor composite, and you cross out every integer that is a multiple of 2. Once you reach the end of the table, you return to the beginning and start with the first integer greater than 2 that is not crossed out. This integer happens to be 3, now go through the table and cross out every integer that is a multiple of 3, then return to the beginning and start at the first integer greater than 3 that is not crossed out; namely 5, and cross out any integers that are not crossed out, and are multiples of 5. Then just continue this process on until you reach the greatest integer less than or equal to n, because if a number n is composite, then it will have a divisor less than or equal to n. I will prove this a little bit later in this paper. Below is the sieve of Eratosthenes for n = 100. All primes less than 100 will be boxed in, and all composites will be crossed out with a slash. Sieve of Eratosthenes for n = 100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Page 2
So now we have looked at a list of primes between 1 and 100, next it will be beneficial to examine some of the simpler special properties involved with prime numbers. We begin with a set of Lemmas that we will use to prove The Fundamental Theorem of Arithmetic. Lemma 1: A prime p is either relatively prime to an integer n or p n. Proof: Since p is prime then by definition, the only factors of p are ±1 or ± p. Thus, (p, n) = 1, or (p, n) = p. If (p, n) = 1 then they are relatively prime, and if (p, n) = p then p p and p n. So if p is prime then p is either relatively prime n or p n. QED Lemma 2: A prime p divides a product ab only when p a or p b. Proof: Let p ab then if p a then (p, a) = 1 which implies that there is some linear combination of p and a that equals 1 px + ay = 1 for some integers x and y. If we multiply both sides by b we get pbx + aby = b, but we know since p ab then there exist some c such that ab = pc. Substituting this in we get pbx + pcy = p(bx + cy) = b which implies that b is a multiple of p and thus p b. So if p ab, then either p a or p b. QED Note that this argument can be extended to encompass a product of more than just two factors. So if p is prime and p a a a then p a for some i. Lemma 3: If n is the product of prime factors, and if p prime and we have p n, then p is one of the prime factors of n. Proof: Let n = q q q be a product of prime numbers and p n then by Lemma 2 we know that p q for one of the q s. So if p q and both are prime then p = q. QED Page 3
Lemma 4: Every number n > 1 can be written as a product of prime divisors. Proof (By Strong Induction): Basis Step: If n = 2 then it can be written as a product of a single prime, itself. Inductive Step: Suppose that every integer n = 2,3,, k can be written as a product of primes. Then consider the integer k + 1, if it is prime, then we are done, if it is composite then we have k + 1 = ab where 1 < a k and 1 < b k so a and b can be written as the product of primes, so a = p p p and b = q q q which means that k + 1 = ab = (p p p )(q q q ) so k + 1 can be written as a product of primes Thus by Strong Induction we have shown that for any n > 1, n can be written as a product of primes. QED (Eynden, 2006) Now after looking at some of the simpler properties of prime numbers, we are ready to look at the most important theorem about prime factorization, The Fundamental Theorem of Arithmetic. Fundamental Theorem of Arithmetic: Every integer n > 1 can be factored into primes, and moreover this factorization is unique up to the order of the factors. Proof: Lemma 4 shows us that every n > 1 can be factored into primes, all that is left it to show the uniqueness of this factorization. Let us suppose that there exist two factorizations for n = p p p = q q q. Since each p divides n = q q q, then by Lemma 3 we know that each p = q for some j. Conversely we see that each q is equal to some p as well. This shows that each factorization of n contains the same prime numbers, the only difference may be if one prime occurs more times in one factorization than in the other. If this is the case however, Page 4
and a occurs more times in the p factorization than in the q factorization, we can simply cancel a repeatedly until we have one or more a s on the p side, and none left on the q side. This would contradict Lemma 3, and thus each prime appears the same number of times in each factorization. Therefore we have shown that every integer n > 1 has a unique prime factorization. This idea of unique prime factorization, as well as the four lemmas that we used to prove this theorem can be found in Euclid s Elements in books VII and IX. (Ore, 1948) Determining Prime Factorization Trial and Error The actual determination of the prime factorization of a number is a problem that has many important applications in the field of Number Theory, unfortunately it is not an easy problem to solve, and for numbers that are very large, it can be so overwhelming that it seems impossible. The most common strategy for factoring involves checking all the prime numbers starting with the smallest, and working to the larger ones. The only reprieve is that we do not have to check every single prime number less than the number we are trying to factor. We only need to check up to the largest prime number less than or equal to the square root of our number. This is because if a number is composite, it will have a factor less than or equal to its square root. To prove this look at n = ab if both a > n and b > n then ab > n n = n so ab > n. Therefore either a < n or b < n, (Note it cannot be both since then ab < n). So if n is composite then it has a factor less than or equal to n. Page 5
To continue our strategy, once we find a prime number, p, that divides our number we are trying to factor, n, then we have n = p m, then we find the first prime factor of m in the same fashion that we found p, and continue on until m is itself a prime number, then we have the complete prime factorization of n = p p p m. Another useful observation is that when the smallest prime, p, is divided out of n, if p > n then the other factor is automatically prime. To prove this we look at n = pm, if m is not prime then m = ab and since p was the smallest prime that divides n we have n = pab with a > p > n and b > p > n. This implies that n = pab > n n n = n which is obviously a contradiction, so m must be prime. We can use trial and error to find the prime factorization of a number if the factors are relatively small, but if the prime factors are large numbers then trial and error can be very tedious and inefficient. So we have other methods we can use that will be discussed in the next few subsections. Factor Tables Until the recent advent of computers, factor tables were the most common way to determine the factorization of numbers that are not too large. There are many different styles of factor tables ranging from the very detailed which contains the complete factorization of every number on the table; to much less detailed ones that contain only the smallest factor of each number, and do not include any number divisible by a single digit prime. The first sizable factor table was published in 1659 by Rahn (or Rohnius) in an appendix to an algebra book. It contained the numbers up to 24,000 excluding those divisible by 2 and 5. A few years later in 1668, a Englishman named Bracker translated this Page 6
work where the tables were extended to 100,000 by John Pell. These tables were the only ones available for a very long time. However, during the eighteenth century there was considerable interest in the field of Number Theory, and as such there became a higher demand for tables with larger values. Only one such table was ever published however. In 1776 Felkel published his table that extended out to 408,000, which was only a small portion of a more ambitious project spanning several million, most of which was ready as a manuscript. The table was published by the Austrian government, but there were very few people who purchased copies. As a result the Austrian government confiscated all but a handful of copies and used them to pack cartridges in a war against the Turks. (Ore, 1948) The size of the factor tables was substantially increased during the 1800 s. All numbers up to 10,000,000 were covered by the combined efforts of Chernac, Burckhardt, Crelle, Glaisher, and Dase. They had them published in ten volumes that each contained a separate million. The most notable achievement however was tabulated by J. P. Kulik, a professor at the University of Prague which gives the factorization of every number up to 100,000,000. This manuscript was never published, however it was placed in the library at the Vienna Academy. (Ore, 1948) Although using factorization tables was considered to be the easiest way to factor relatively small numbers, the question arises of how do we try to factor large numbers that are beyond the realm of factor tables? A couple possible answers come to us from the great minds of Pierre de Fermat, and Leonhard Euler. Page 7
Fermat s Method of Factorization Pierre de Fermat was a French Mathematician and Lawyer. He lived from 1601 to 1665 in the city of Toulouse. He is routinely noted as the first person to think of number theory as a systematic science. Fermat enjoyed literary studies and also wrote poetry, however his true love was most certainly mathematics. His achievements and areas of significant advancement in mathematics alone are far too numerous to list here, however his real passion in mathematics was most certainly number theory. He gained great pleasure in proposing new and difficult problems, as well as giving solutions that require extremely elaborate and difficult computations. In this paper, we are particularly interested in his method of factorization. This method of factorization is based upon the fact that if a number can be written as the difference of two squares, then it factors quite nicely. In particular we have: n = x y = (x + y)(x y) So since we have a composite n, then we can say that n = ab with b a, so setting a = x y and b = x + y. By solving for x and y we get x = and y =. Now because of the fact that we are dealing with factoring, we can assume that before we tried to factor n, we first factored out the highest power of 2 possible, thus leaving n to be odd. Therefore we know that both a and b are also both odd, which means that x and y are both integers. To determine the possible values of x and y we see that x = n + y x n x n Page 8
So the procedure begins by looking at x values that are successively larger than n, and the difference between the square of x and n to see if it is a perfect square. In other words: x = x n and does this equal y? This calculation can seem like it could get pretty tedious, especially if x gets extremely large. However, thankfully there is a short cut to calculating x, and it stems from the equation: (x + 1) n = x + 2x + 1 n = x n + 2x + 1 So we get (x + 1) = x + 2x + 1 And by repeatedly applying this rule we get (x + 2) = (x + 1) + 2x + 3 (x + 3) = (x + 2) + 2x + 5 and so on This lets us compute each successive x by simple addition. So let us take a look at Fermat s method implemented on the number 2,027,651,281, which is a number to which Fermat himself applied his method of factorization. The first integer greater than n is 45,030, and the calculations are as follows: x = 45,030 x = 49,619 2x + 1 = 90,061 45031 (x + 1) = 139,680 2x + 3 = 90,063 45032 (x + 2) = 229,743 2x + 5 = 90,065 45033 (x + 3) = 319,808 2x + 7 = 90,067 45034 (x + 4) = 409,875 2x + 9 = 90,069 45035 (x + 5) = 499,944 2x + 11 = 90,071 Page 9
45036 (x + 6) = 590,015 2x + 13 = 90,073 45037 (x + 7) = 680,088 2x + 15 = 90,075 45038 (x + 8) = 770,163 2x + 17 = 90,077 45039 (x + 9) = 860,240 2x + 19 = 90,079 45040 (x + 10) = 950,319 2x + 21 = 90,081 45041 (x + 11) = 1,040,400 = 1,020 = y This shows that n = (45,041 + 1,020)(45,041 1,020) = 46,061 44,021 It is important to note that Fermat s method of factorization is particularly useful when the difference between the factors is relatively small. This way the desired y will quickly be found, as is apparent in his choice of example discussed above. Euler s Factorization Method: Leonhard Euler was an amazing scientist, whose contributions are evident on nearly every branch of mathematics. The sheer volume of work that he did in his lifetime is unreal; it has been said that his entire collected works would fill the pages of over 100 large books. Born in Switzerland in 1707, he held positions at the Academy of St. Petersburg as well as the Academy of Berlin. He first mentions factorization of a number using the representation of the sum of two squares in a letter on February 16, 1745 to Christian Goldbach, a German mathematician. This is what we are interested in here. Euler s factorization method only applies to numbers, which can be represented in at least two different ways as the sum of two perfect squares, so n = a + b. We begin just as we did in Fermat s method, we will assume that n is of odd parity, so one of the numbers Page 10
is odd and the other is even. So without loss of generality we can say that a is odd, and b is even. The next step in Euler s factorization is to look at the second way to represent n as the sum of two squares, so n = c + d. Where again we have c is odd, and d is even. For example if n = 221 then we have n = 11 + 10 = 5 + 14. To show that the two representations of n = a + b = c + d leads us to a factorization of n, we look at a + b = c + d a c = d b (a c)(a + c) = (d b)(d + b) Now let k = gcd(a c, d b) noting that k is even since a c and d b are both even. So we have a c = kl and d b = km with gcd(l, m) = 1. Substituting these in we get kl(a + c) = km(d + b) l(a + c) = m(d + b) so since l and m are relatively prime then m must divide a + c, which gives a + c = mr lmr = m(d + b) lr = (d + b). So we have a + c = mr and d + b = lr but (l, m) = 1 so this means that r = gcd(a + c, d + b), and thus is also even. So the factorization that we are looking for is: n = k 2 + r 2 (m + l ) To prove this factorization is valid we simply multiply out the right hand side of the equation to get: (k m + k l + r m + r l ) = [(km) + (kl) + (rm) + (rl) ] and now substituting all the values from above we arrive at Page 11
1 4 [(d b) + (a c) + (a + c) + (d + b) ] = 1 4 [d 2db + b + a 2ac + c + a + 2ac + c + d + 2db + b ] = 1 4 [2d + 2b + 2a + 2c ] = 1 4 [2(a + b ) + 2(c + d )] = 1 [2n + 2n] = n 4 So we see that this factorization is in fact a valid one. Now let us do an example by factoring the number n = 2501. It is apparent that 2501 = 50 + 1, and after some minor calculations we can see that 2501 = 49 + 10 as well. So we can let a = 1, b = 50, c = 49 and d = 10. Then a c = 48, a + c = 50, d b = 40, and d + b = 60, so this leads to k = 8, l = 6, m = 5, and r = 10. Which in turn tells us that the factorization of 2501= + (5 + 6 ) = (4 + 5 )(5 + 6 ) = 41 61 Conclusion In this paper we looked at some of the ancient methods of factoring, and showed that we can factor some numbers if they have a special form. However if I have a number that I need to factor that is not in one of those special forms, then the only method that we discussed was to use a factor table. So again we still have the question of how do we factor numbers that are larger than the factor tables we have access to. In the next paper on prime factorization I will attempt to discuss some of the more modern methods of prime factorization, and will also include some of the current applications of prime factorizations like RSA public key cryptography. I also intend on looking at some of the ways that prime numbers are generated today. Page 12
Bibliography Derbyshire, J. (2004). Prime Obsession: Bernhard Riemann and the Greates Unsolved Problem in Mathematics. New York: Penguin Group. Eynden, C. V. (2006). Elementary Number Theory. Long Grove: Waveland Press,Inc. Goldstein, C. (1992). On a Seventeenth Century Version of the Fundamental Theorem of Arithmetic". Historia Mathematica, 177-187. Kaempffert, W. (1933, March 12). The Week in Science: A New Calculator. The New York Times, p. 4. Ore, O. (1948). Number Theory and Its History. New York: McGraw-Hill Book Company. Page, R. L. (2004). Number Theory, Elementary. In Encyclopedia of Physical Science and Technology (pp. 15-38). Elsevier Science Ltd. Stein, W. (2008). Elementary Number Theory: Primes, Congruences, and Secrets. Springer-Verlag. Weisstein, E. W. (n.d.). Sieve of Eratosthenes. Retrieved 3 23, 2011, from MathWorld--A Wolfram Web Resource: http://mathworld.wolfram.com/sieveoferatosthenes.html Page 13