-1

I am trying to understand the algorithm for calculating combination N Choose R. It basically relies on the fact that $(N)/1 * (N-1)/2 * (N-2)/3 * ... * (N-R+1)/R$ is always an integer for any $R$.

It is obvious that the numerator is divisible by any number in the denominator, but I don't understand how the numerator is divisible by all numbers in the denominator. For two co-prime numbers, it makes sense, but what about numbers that aren't coprime to each other?

For example, consider this: $(N)/1 * (N-1)/2 * (N-2)/3 * (N-3)/4 * (N-4)/5 * (N-5)/6$. What if 4 needs $N-3=12$ and 6 needs $N-3=12$. Individually, $N-3$ is divisble by 4 or 6, but $N-3$ is not divisible by 24.

https://stackoverflow.com/questions/9330915/number-of-combinations-n-choose-r-in-c https://stackoverflow.com/questions/1838368/calculating-the-amount-of-combinations

Eric Wofsey
  • 330,363
JobHunter69
  • 3,355

1 Answers1

0

The individual number-to-number fraction product does not have all integer values. It is the total denominator product that divides the numerator product. Another way to phrase this is by saying that the product of any $r$ consecutive positive integers is divisible by $r!$ (i.e. the product of the first $r$ consecutive positive integers). Combinatorially speaking, the fact that this value is the number of ways of choosing objects is proof of divisibility, but I shall try to reason this in a intuitive number-theoretic manner.

Consider the prime factorization of $r!$. Let $p^k$ be the largest power of $p$ that divides $r!$. It suffices to show that the product of any $r$ consecutive positive integers is divisible by $p^k$. For any product of numbers, we can see that the power of $p$ dividing this product is: $$n_1+n_2+n_3+\cdots$$ where $n_i$ is the number of values in the product divisible by $p^i$. This is because if the maximum power of $p$ dividing a certain term in the product is $p^i$, then it is counted $i$ times in the above sum (in $n_1,n_2,\cdots,n_i$).

Now, we show that this sum is least when our $r$ consecutive numbers are the first $r$ positive integers, and this would show that since $r!$ is the case where power of $p$ is least, we would also have $p^k$ dividing any product of $r$ consecutive positive integers.

To minimize $n_1$, what would are first number in our $r$ consecutive numbers have to satisfy? Well, it is minimized when the first number is $1 \pmod{p}$ since that way, it delays the occurrence of the first number divisible by $p$ as long as possible. For example, if $r=9$ and $p=5$, if the first number was $1 \pmod{5}$, there would only be $1$ number in the product that is divisible by $5$, but in any other case, there would be $2$ numbers divisible by $5$.

It similarly works that for any $n_i$, the way to minimize $n_i$ is by making the first number $1 \pmod{p^i}$. Now, it becomes evident why $1,2,3,\cdots,r$ minimizes the power of $p$. The first term, $1$, is $1 \pmod{p^i}$ for all integers $i$! It is in some sense, the farthest away from all the numbers divisible by $p$! Hope this provides a nice intuitive perspective to the divisibility aspect!

Haran
  • 9,717
  • 1
  • 13
  • 47