Binomials

LaTeX4Web 1.4 OUTPUT Binomial coefficients can be written as C(n,k) and they express the number of ways of choosing k out of n items without replacement and disregarding the order pick. They can be computed using the expression C(n,k) = n!/k!(n-k)!, which uses the factorial function. Binomial coefficients also appear in polynomial expansions, as Newton explained in the binomial theorem. Moreover, they can be placed into a triangular array known as Pascal¢s Triangle. This disposition follows the relationship C(n,k) + C(n,k+1) = C(n+1, k+1), which means that any term in the triangle is equal to the sum of the previous two terms.
LaTeX4Web 1.4 OUTPUT In order to compute binomial coefficients, it is not advised to use the factorial function, because numbers become too large very quickly. Instead, we can use Pascal¢s Triangle since it only requires the addition of numbers. Here we provide the code for computing any binomial coefficient using Pascal¢s Triangle. Note that the binomial coefficient C(n,k) is equal to the number that is placed in the nth row and the kth position in the row.
Binomial.txt Binomial.txt
Size : 1.672 Kb
Type : txt

Here you can see an example of the output of the code. 

It is interesting to analyze Pascal's Triangle a little bit more. The following picture illustrates the triangular array, in which you can observe that each term equals the sum of the previous two terms.

Then a question arises: what if we represent Pascal's  Triangle modulo some prime? Here we provide the code to do so using any prime. The code also counts how many numbers in the displayed triangle are divisible by the chosen prime and how many are not.

PascalModP.txt PascalModP.txt
Size : 1.104 Kb
Type : txt

Here you can find an example of the output of the code using modulo 2. Note that if there is a 0 it means that the corresponding binomial coefficient is divisible by 2, and if there is a 1 it means that the corresponding binomial coefficient is not divisible by 2.

You can see that we obtain Sierpinski's Triangle, which is a fractal in the form of equilateral triangles. In the following picture you can see how Sierpinski's Triangle is constructed and compare it to the picture above.

In general, depending on the prime we will obtain different variations of Sierpinski's Triangle. We can compare the number of entries in the Triangle that are not divisible by the chosen prime as the Triangle grows large. We can plot the number of entries that are not divisible by the chosen prime in function of the number of rows in Pascal's Triangle and then linearize the results. We obtain an almost perfect line for modulo 2, 3, 5 and 7. In the following pictures you can observe the plots with the results.