Archive for October 19, 2010
Fun Factor
Two numbers were having a conversation about their social lives.
28: Did you hear that 284 broke up with 220?
6: I’m not surprised. He’s far from perfect. But at least their breakup was amicable.
28: Yeah, well, I heard she started seeing 12.
6: Really? He doesn’t have abundant charm. Don’t you think 10 would be a better match for her?
28: I don’t know. He seems so solitary!
Speaking of factors, I learned a neat trick this weekend for finding the sum of the factors of a number. Before I share that, consider the method for determining how many factors a number has. Take the number 12, for instance. The prime factorization of 12 is:
12 = 2^{2} × 3
The following array can be used to generate all of the factors of 12:

2^{0}  2^{1}  2^{2} 
3^{0}  1  2  4 
3^{1}  3  6  12 
It’s obvious from the array that there are six factors. But the trick is to notice that each factor in the array is made from a power of 2 times a power of 3 — that is, each factor is equal to 2^{m} × 3^{n}, where 0 ≤ m ≤ 2 and 0 ≤ n ≤ 1. Since there are three possible values of m and two possible values for n, then there are 3 × 2 = 6 factors of 12.
In general, if the prime factorization of the number takes the form a^{p} × b^{q} × c^{r}, then the number of factors is (p + 1)(q + 1)(r + 1) for exponents p, q, and r. (The process could obviously be extended if there are more than three prime factors.)
But look at the array again. The sum of all factors of 12 is equal to sum of all products that occur within the array. However, there is an easy way to find that sum, by taking advantage of the distributive property. The sum of the powers of 2 along the top is 2^{0} + 2^{1} + 2^{2} = 7, and the sum of the powers of 3 along the left side is 3^{0} + 3^{1} = 4. Consequently, the sum of all factors of 12 is equal to:
(2^{0} + 2^{1} + 2^{2})(3^{0} + 3^{1}) = 7 × 4 = 28
In general, if the prime factorization of a number is a^{p} × b^{q} × c^{r}, then the sum of the factors is:
(a^{0} + a^{1} + … + a^{p})(b^{0} + b^{1} + … + b^{q})(c^{0} + c^{1} + … + c^{r})
And again, this could be extended if the number had more than three prime factors.
Cool, huh?