Lecture 14 - Adding Up Divisors


We started today's class with a little observation of how number theory creeps into our daily lives without our realizing. We then spent the lion's share of the class discussing the function $\sigma$ which adds up the divisors of a given integers. We gave a formula which lets us compute $\sigma(n)$ provided we have a prime factorization of n. We also saw a handful of results which described some properties of this function.

Number Theory in the Real World: Check Digits

On Wednesday I mailed two documents and asked for delivery confirmation. With both documents I received a 20 digit number that was meant to identify each document in case I needed to check on delivery or whatever. I noticed that the numbers looked awful similar, but they weren't sequential. I won't put the real numbers here since any old crazy might be able to find them on the internet, but I'll post numbers which are representative:

\begin{split} 3141 \quad 5926 \quad 5358 \quad 9793 \quad 2383 &\quad \quad\mbox{Document 1}\\ 3141 \quad 5926 \quad 5358 \quad 9793 \quad 2390 &\quad \quad\mbox{Document 2} \end{split}

I noticed that these numbers are nearly sequential, and that if you cut off the last digit of each number they would be sequential. This tipped me off that the first 19 digits must be the package's number, and that the last digit is a so-called "check digit."

Here's a little background: when a person has to type in long strings of numbers, it often happens that the person will screw up what they've typed. The two most common mistakes are

  • to mistype one number
  • to switch two adjacent numbers.

Of course making these mistakes can be problematic, especially when a person doesn't realize that they've made the mistake. A check digit is meant to be a number which determines whether or not a person has made a mistake in data entry. The idea is that if a person does screw up somehow in typing in the numbers, then the check digit they type wouldn't match up with the other numbers they've entered. This tells the computer that there must be an error in the number it's been given, and the computer can then ask the typer to rekey the entry.

Check digits at the post office

It turns out that the last digits in the confirmation numbers from my post office receipt were, indeed, check digits, and that the post office uses a "weighted Mod 10" algorithm for computing these check digits.

Here's how it works:

  • out of the first 19 digits in your number, let A be the sum of all the digits that are in an odd position (e.g., the first, third, eleventh, etc. positions)
  • out of the first 19 digits in the number, let B be the sum of all the digits that are in an even position (e.g., the second, tenth and so on).
  • compute 3A + B
  • the check digit is the number one needs to add to 3A+B in order to get something divisible by 10

Example: Computing a check digit for the post office

The first 19 digits of the first package number were: 3141 5926 5358 9793 238. The numbers in the odd positions are 3, 4, 5, 2, 5, 5, 9, 9, 2, 8, so that $A = 52$. The numbers in the even positions are 1, 1, 9, 6, 3, 8, 7, 3, 3, so that $B = 41$. Hence $3A + B = 197$, and so the check digit should be (and is!) 3.

Check digits on credit cards

A similar trick is used when issuing credit card numbers, though a different algorithm is used. Most credit card numbers have 16 digits, and usually the last digit is a check digit. Here's how it works: take the first 15 digits of your credit card number. For the sake of concreteness, let's say I have a credit card whose first 15 digits are

\begin{align} 1234 \quad 5678 \quad 9012 \quad 345. \end{align}

What should the last digit be?

I'll go through 2 steps to answer this question. First, I take every digit in an odd position and double it, while ever digit in an even position stays unchanged:

Unsupported math environment "tabular"

Now I take these new digits and reduce any 2 digit number into a 1 digit number by "casting out nines," which means I just add up the digits of the 2 digit number to make a 1 digit number. For example, 14 becomes $1+4 =5$, and 22 would become $2+2 = 4$. I'll represent this in the third row below:

Unsupported math environment "tabular"

Now I'll just add up the digits in the last row:

\begin{equation} 2+2+6+4+1+6+5+8+9+0+2+2+6+4+1 = 58. \end{equation}

Now the last digit of my card should be the number I need to add to 58 in order to get something divisible by 10; in this case, that means the last digit should be 2. Hence we know that

\begin{align} 1234 \quad 5678 \quad 9012 \quad 3452 \end{align}

has the appropriate check digit, and therefore a chance at being a valid credit card number. On the other hand,

\begin{split} 1234 \quad 5678 &\quad 9012 \quad 3451\\ 1234 \quad 5678 &\quad 9012 \quad 3453\\ 1234 \quad 5678 &\quad 9012 \quad 3454\\ 1234 \quad 5678 &\quad 9012 \quad 3455\\ &\vdots \end{split}

have NO chance of being valid credit card numbers since their check digits aren't correct.

(Of course, this isn't the only security measure that credit card issuers take, so don't think that the number we gave above actually is a valid credit card number.)

This makes for a good trick to impress your friends. For those who are interested, it's called the Luhn algorithm.

The Sigma Function

Today in class we're going to introduce a new arithmetic function: the $\sigma$ function.

Definition: For a given integer n, the $\sigma$ function is gives the sum of the divisors of n:

$\displaystyle \sigma(n) = \sum_{d \mid n} d.$

Example: Computing $\sigma$ for some small numbers.

With the definition of $\sigma$ in hand, we can use it to compute the value of $\sigma$ for a few numbers. In class we saw

\begin{align} \sigma(6) = 1 + 2 + 3 + 6 = 12 \end{align}

and that

\begin{align} \sigma(15) = 1+3 + 5 + 15 = 24. \end{align}

Notice that computing $\sigma$ for these two numbers was easy since it was easy to write out all the divisors of these numbers. We could pursue a similar method for computing $\sigma(120)$, but since it has more divisors this would be a pain to carry out. $\square$

If we want to compute $\sigma(n)$ for larger values of n, it will be useful for us to have a better method for calculating the sum of the divisors of a number aside from listing out all the divisors and adding them up. As with the other arithmetic functions we've considered, we'll be able to find a simpler formula if we can first determine whether this new function is multiplicative.

Proposition: The $\sigma$ function is multiplicative.

Proof: We have a result from a while back that shows any multiplicative function f can be used to define another multiplicative function $F(n) = \sum_{d\mid n} f(d)$. We'll show that $f(d)=d$ is multiplicative, and is in fact completely multiplicative. So let a,b be two numbers. Of course we have $f(ab) = ab$. But notice we also have $f(a) = a$ and $f(b) = b$, so that $f(a)f(b) = ab$. Hence we have

\begin{equation} f(ab) = ab = f(a)f(b), \end{equation}

and hence f is completely multiplicative.

Now since f is multiplicative, we have

\begin{align} \sigma(n) = \sum_{d\mid n}d \end{align}

is also multiplicative. $\square$

Remark: Just because the function f in our proof is completely multiplicative doesn't mean that $\sigma(n) = \sum_{d \mid n} f(d)$ is also completely multiplicative!

Knowing that $\sigma$ is multiplicative gives a huge advantage when it comes to computing the value of $\sigma$ for a particular number, since we now know that $\sigma$'s value can be determined by examining what it does to prime powers: if $n = p_1^{e_1}\cdots p_k^{e_k}$, then

\begin{align} \sigma(n) = \sigma(p_1^{e_1})\cdots \sigma(p_k^{e_k}). \end{align}

With that as motivation, notice that since the divisors of a prime power $p^a$ are given by $\{1,p,p^2,\cdots,p^a\}$, we have

\begin{align} \begin{split} \sigma(p^a) &= 1 + p + p^2 + \cdots + p^a = \sum_{i=0}^a p^i. \end{split} \end{align}

This is a geometric series, so we can use the formula for the sum of a geometric series to compute

\begin{align} \begin{split} \sigma(p^a) &= \sum_{i=0}^a p^i = \frac{p^{a+1}-1}{p-1}. \end{split} \end{align}

Corollary: For a number $n = p_1^{a_1}\cdots p_k^{a_k}$, we have

$\displaystyle \sigma(n) = \prod_{i=1}^k \frac{p_i^{a_i+1}-1}{p_i-1}$.

Example: Summing divisors of some larger numbers

Suppose we wanted to compute $\sigma(28)$. Since $28 = 4 \cdot 7 = 2^2 \cdot 7^1$, our formula gives

\begin{align} \sigma(28) = \left(\frac{2^3-1}{2-1}\right)\left(\frac{7^2-1}{7-1}\right) = 7 \cdot 8 = 56. \end{align}

Likewise, if we want to compute $\sigma(120)$, then since $120 = 8 \cdot 3 \cdot 5 = 2^3 \cdot 3^1 \cdot 5^1$ we have

\begin{align} \sigma(120) = \left(\frac{2^4-1}{2-1}\right)\left(\frac{3^2-1}{3-1}\right)\left(\frac{5^2-1}{5-1}\right) = 360. \end{align}


Carl pointed out that if a prime appears to the first power in the prime decomposition of n, then the corresponding term in $\sigma(n)$ is just $p+1$:

\begin{align} \left(\frac{p^2-1}{p-1}\right) = p+1. \end{align}

Note only does this observation match up with our formula, but it also follows from the definition of $\sigma$: if p is prime then its only divisors are 1 and p, so that $\sigma(p) = 1+p$. We'll record this as a helpful

Observation: If p is prime, then $\sigma(p) = p+1$.

Interesting Properties of the Sigma Function

Now that we know how to evaluate the $\sigma$ function, let's try to come up with a few interesting properties of the $\sigma$ function.

Detecting Primality

The first such property will be a result that tells us the $\sigma$ function can be used to characterize prime numbers.

Lemma: A number n is composite if and only if $\sigma(n) > n+\root\of{n}$.

Proof: First, assume that n is composite. An old result tells us that there is a prime divisor p of n which satisfies $p\leq \root\of{n}$. Hence the integer $\frac{n}{p}$ is a divisor of n with $\frac{n}{p}\geq \root\of{n}$, and furthermore we must have $1 < \frac{n}{p} < n$.

Now if we want to compute $\sigma(n)$ we should add up all its positive divisors. Notice, however, that this sum of all divisors is at least as big as the sum of the 3 divisors [[$\{1,\frac{n}{p},n\}$ of n — after all, we're just throwing away the remaining divisors of n, so the sum of these three divisors is no bigger than the sum of all the divisors. Hence we have

\begin{align} \sigma(n) = \sum_{d\mid n} d \geq 1 + \frac{n}{p} + n \geq 1 + \root\of{n} + n > \root\of{n}+n. \end{align}

So we have shown that when n is composite, $\sigma(n)$ is appropriately "big."

To prove the converse, we'll show that when n is prime, then $\sigma(n)$ is "small". In fact, we've already seen that if n is prime, then we have $\sigma(n) = n+1 < n+\root\of{n}$. $\square$

Remark It is worth noting that even though this theorem does give a bona fide way of testing whether an integer is prime, it doesn't give a very practical method for doing so. After all, the 2 ways we have of computing $\sigma(n)$ rely on either knowing all divisors of n (in which case you'll be able to tell pretty quickly whether the number is prime) or on the prime factorization of n (in which case, again, you will already be able to tell if the number is prime).

Evenness and Oddness

As with the $\nu$ function, one might be curious to know which integers n have $\sigma(n)$ an odd number. For this, we note that a number $n=p_1^{a_1}\cdots p_k^{a_k}$ has

\begin{align} \sigma(n) = \prod_{i=1}^k \frac{p_i^{a_i+1}-1}{p_i-1}, \end{align}

so that $\sigma(n)$ is odd if and only if all these factors of $\sigma(n)$ are odd.

First, if one of the $p_i=2$, then we have

\begin{align} \frac{p_i^{a_i+1}-1}{p_i-1} = \frac{2^{a_i+1}-1}{2-1} = 2^{a_i+1}-1, \end{align}

which is always an odd number (regardless of the value of $a_i$. Hence the power of 2 which appears in the prime factorization of n is of no consequence to this question.

Now suppose that $p_i>2$, so that $p_i$ is odd. Then we have

\begin{align} \frac{p_i^{a_i+1}-1}{p_i-1} = 1+p_i+p_i^2+\cdots+p_i^{a_i}. \end{align}

Notice that each of the summands in this sum are odd numbers (since each is a power of an odd number, and you have proven that the product of odd numbers is odd). Hence this sum is odd if and only if the number of terms in the sum is odd, and we can see that the number of terms in the sum is $a_i+1$. Hence if we want this term to be odd, we need $a_i$ to be even. We have proven the following

Lemma: An integer n has $\sigma(n)$ odd if and only if $n=2^e\cdot s^2$, where s is an odd integer.

Summing Powers of Divisors

We finished class by discussing a generalization of the $\sigma$ function.

Definition: For a given integer n, the $\sigma_k$ function is gives the sum of the k-th powers of the divisors of n.

In equation form, the definition of $\sigma_k$ says

\begin{align} \sigma_k(n) = \sum_{d \mid n} d^k. \end{align}

One final note: the function $\sigma_0(n)$ is defined as $\sigma_0(n) = \sum_{d\mid n} d^0 = \sum_{d \mid n} 1$, and hence we see that $\sigma_0 = \nu$. It's also easy to see that $\sigma_1(n) = \sum_{d \mid n} d^1 = \sum_{d \mid n} d = \sigma(n)$.

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License