Binomial Coefficients Module Prime
First we’re going to look at the binomial coefficients modulo 2. When we build Pascal’s triangle modulo 2, we will get the following diagram.
Now, observe the patterns that the zeros are making. One obvious thing to notice is that when the row is a power of 2, almost all coefficients become 0. So now the question is, does this happen for other primes? do rows vanish when they’re divisible by this prime? For example, if we do this for 3. Then we get the following
Note here that the dark square is 2, the light square 1 and the empty squares represent 0. So we do get the same pattern. All the rows divisible by 3 mostly vanish. It turns out, this happens for any prime \(p\). In general
One way to show this is by using the explicit definition
Observe here that \(p!\) is divisible by \(p\). \(k!\) and \((p-k)!\) are only divisible by \(p\) if \(k = 0\) or \(k = p\). So as long as \(0 < k < p\), we know that \(\binom{p}{k} \bmod p = 0\). This property about primes and binomial coefficients gives us the following application. Consider expanding \((x+y)^p\). Then we would get something like \((x+y)^p = x^p + y^p + p(\)some other term\()\). For example
So all the other terms are multiples of 5. So when we take this module 5, you will see that
In general,
What about \(p^2\)? observe that
Thus
# of Times a Prime Divides a Binomial Coefficient
Sometimes it is useful to know how many times does a prime divides a binomial coefficient. Recall that the explicit definition is \(\binom{n}{k} = \frac{n!}{(n-k)!}\). First, take the numerator. How many times does \(p\) divide \(n!\)? For example, how many times does 2 divide \(8!\)? Write the expansion of \(8!\) as follows
We have 4 even numbers. Each one of them divides 2. So we have \(2^4\) as a factor. We can add an extra factor of 2 for \(4\) and \(8\). Finally, we still need to a final factor of 2 for 8. So we have \(2^7\). In general, if we want to know how many times does \(p\) divide \(n!\), then we list the numbers from \(1\) all the way to \(n\) which will include numbers divisible by \(p\) like \(p\) itself, \(2p\) and other multiples of \(p\). So
Intuitively, it is easy to see that we just need to know how many copies of \(p\) are \(n\). In fact, there are \([\frac{n}{p}]\) copies where \([]\) means the integer part of the number. That’s not everything though since \(p^2\) is also divisible by \(p\) so we want to count all the copies of \(p^2\) as well and that’s \([\frac{n}{p^2}]\). Similarly, we need to count the number of copies of \(p^3\), \(p^4\) and so. Thus, the total number of times \(p\) divides \(n!\) is
Observe now that this sum is slightly less than the geometric series
Example 1
Take 1000! how many zeros does it have? so we want to count how many times does 2 divide 1000! and also how many times does 5 divide this number. The number of times 5 divides 1000! is
But note here that once we compute \(\left[\frac{1000}{5}\right] = 200\), then for the next computation, we just divide this number by 5 again.
Similarly for 2,
But we don’t need to continue dividing as we have already passed the count of 249 in step 1. We stop since now we have exactly 249 zeros.
Example 2
Suppose we want to find the number of times 7 divides \(\binom{100}{40}\). The number of times 7 divides 100 is
So we have 7 dividing 100 16 times. While the number of times 7 divides 40 is
is just 5 times. Finally, the number of times 7 divides 7 is
So it’s 9 times. Thus, the number of times 7 divides \(\binom{100}{40}\) is \(16 - 5 - 9 = 2\).
How Big are Binomial Coefficients?
A crude estimate would be to look at the sum of the \(n\)th row in Pascal’s triangle which we found in the last lecture to be \(2^n\). Thus
We can also give a lower bound by observing that
and noticing here that we have exactly \(2n+1\) terms and that \(\binom{2n}{k}\) is the largest coefficient among these \(2n+1\) coefficients. If we assume that every single coefficient is as large as the largest one, then
which then gives us the bound
We can also use Stirling’s Formula to precisely compute the binomial coefficients using
An Upper Bound on the Number of Primes \(\leq n\)?
As an application, we can try to estimate how many primes are there that are less than or equal to \(n\). Let the number of primes \(\leq n\) be \(\pi(n)\). The prime number theorem gives us the estimate of \(\pi(n) \approx \frac{n}{\log n}\). However, the prime number theorem is difficult to prove. So we will instead use the binomial coefficients to prove a slightly weaker version of it as follows
The key idea is to look at the binomial coefficient of \(\binom{2n}{n}\) and the number of primes diving it. So suppose that \(2 < p < 2n\). Then \(p\) divides \(\binom{2n}{n}\) exactly once. why?
\(p\) divides \(2n!\) but it doesn’t divide \(n!\). So \(p\) divides \(\binom{2n}{n}\) once. Now, take the product of all primes \(p\) between \(2\) and \(2n\). Each one of these primes divides \(\binom{2n}{n}\) once. so their product must divide \(\binom{2n}{n}\) as well
And this gives the lower bound below
But we already saw earlier that we can also bound \(\binom{2n}{n}\) as follows
So now let’s take the log of each side
Now, for any prime \(p\) in the interval \([n,2n]\), we know that \(p \geq n\). Thus, \(\log p \geq \log n\). Let \(\pi(n,2n)\) be the number of primes in the interval \([n,2n]\). Then, the sum of logarithms of primes in the interval \([2,2n]\) is at least:
This gives us the inequality
We can now solve for the number of primes to see that
But then with some additional work (TODO?), we can get to
A Lower Bound on the Number of Primes \(\leq n\)?
What about a lower bound on the number of primes? We will again look at the binomial coefficient \(\binom{2n}{n}\). If we take the product of all prime powers less than \(2^n\), then we will get the following bound (WHY?)
[The left hand side is the product of \(k\) copies of \(p\) where \(p^k \leq 2n\).] The number of times \(p\) divides \(\binom{2n}{n}\), can be done similar to example 2. Since \(\binom{2n}{n} = \frac{(2n)!}{n!n!}\), then
However, observe here that the expression \(\left[\frac{2n}{p}\right] - \left[\frac{n}{p}\right] - \left[\frac{n}{p}\right]\) is either 0 or 1 since it is equal to \([2n] - [n] - [n]\) and this is always 1 or 0 depending on the fractional part of \(n\). This means that in the inequality above, for each power of \(p\), we’re going to see that we will get at most 1 copy of \(p\) dividing \(\binom{2n}{n}\). Therefore, the product \(\prod_{p^k \leq 2n} p\) is at least bigger than \(\binom{2n}{n}\).
Furthermore, we saw earlier that that
Combining both inequalities and then taking the logarithms of both sides
So now how do we turn \(\sum_{p^k \leq 2n} \log p\) to counting primes? We need to simplify things further. First, the terms \(p^2\), \(p^3\), and so on are small. Second, \(\log(x)\) is almost constant as \(n\) gets really big. Therefore, \(\log p \approx \log 2n\) for most primes. Thus
In other words,
Catalan Numbers
Take a look at the binomial coefficient \(\binom{2n}{n}\) again. If we write them down, we will get
which we notice that they are divisible by
so \(\binom{2n}{n}\) is always divisible by \(n+1\). The sequence we get after dividing is
This sequence is called the Catalan numbers. They are famous because they count many things. For instance, they count the number of ways to bracket products. So to count the ways to multiply \(abcd\), we will see that there are exactly 5 ways.
Why is this true? Catalan numbers can be described with the following
So if we’re multiply \(n\) numbers together, we can imagine that \(C_0\) represents \(a\), \(C_1\) represents \(ab\), \(C_2\) represents \(abc\) and we can start pairing them as follows
How did the recurrence formula for Catalan numbers came to? For this we again use the powerful tool of generating numbers. So if we let
Then
In fact,
This is a quadratic equation where we can use the quadratic formula to solve it and get
But now recall that
and this works even if \(n\) is not an integer. So we can use this to expand \(\sqrt{1 - 4x}\) in the quadratic formula above. So
If we work this out, we will see that this turns out to be