# Pascal's Triangle Calculator

Welcome to our **Pascal's triangle calculator**, where you will learn how to use Pascal's triangle, as well as why you should use it in the first place. Don't worry, this concept doesn't require any area formulas or unit calculations, like you'd expect for a normal triangle. What is Pascal's triangle then? Well, **it's a neat way to calculate the number of combinations, and visualize binomial expansion**. But, before we begin describing Pascal's triangle patterns, let's start with the basics.

## What is Pascal's triangle?

**Pascal's triangle is a table of numbers** in the shape of an equilateral triangle, where the `k`

-th number in the `n`

-th row tells you how many combinations of k elements there are from a set of n elements (Note that we follow the convention that **the top row, the one with the single 1, is considered to be row zero**, while the first number in a row, also a 1, is considered the 0th number of that row.) Be they films for a movie marathon, European countries to visit this summer, or ingredients from your fridge for tomorrow's dinner, this statement of combinations always remains true (we're pretty sure that the last one is not precisely how cooking works, but some of us have to **make up for a lack of skills with creativity**).

Each number shown in our Pascal's triangle calculator is given by the formula that your math teacher calls the binomial coefficient. The name is not too important, but **let's see what the computation looks like**. If we denote the number of combinations of `k`

elements from an `n`

-element set as `C(n,k)`

, then

`C(n,k) = n! / (k! * (n-k)!)`

.

The exclamation mark in this context is what the mathematicians call a factorial, and is defined as **the product of all numbers up to and including** `n`

, i.e.,

`n! = n * (n-1) * (n-2) * ... * 2 * 1`

.

## How to use Pascal's triangle?

Say that **you're preparing a movie marathon** for yourself and your partner. You have a list of your favorite twenty movies, and your partner told you to pick three that they might like. Well, **these are the best films in existence**, so clearly they will like each and every one of them, and it doesn't really matter which ones you choose. Also, the order in which you're going to watch them doesn't matter either. So how many options are there?

The number you seek is the third number in the twentieth row, 1140. **Magic? Not quite, just mathematics** (but then again, are they that different?). Indeed, according to Pascal's triangle formula, that number corresponds to the expression `C(20,3)`

, which is the number of triples from a set of twenty elements. Or, in our case, **the number of ways we can choose three movies from a pile of twenty**.

## Pascal's triangle patterns

**Blaise Pascal**, a French mathematician after whom the triangle is named, focused on several interesting triangular properties. Indeed the number of combinations, which is encoded as the individual numbers in consecutive rows, was already known during his time. However, **the triangle is often introduced using a much simpler rule**. Observe that apart from the 1s on the far ends of the triangle, each of the other numbers is the sum of the two that are directly above it.

This is precisely the observation (or property if you like) that is frequently used to construct the triangle. Using the Pascal's triangle formula, we can describe this observation:

`C(n,k) = C(n-1,k-1) + C(n-1,k)`

.

In particular, look at the second number from the left in each row. **Each of those has a one to its upper left, and to its upper right is the row number of the previous row**. Therefore, their sum is one plus the previous row number, and the result is the row we are in.

Another one of the numerous interesting **Pascal's triangle patterns is its symmetry**. Observe that in any row, **if we read the consecutive numbers from the left, we will obtain the same as if we read them from the right**. Is it magic or mathematics again? Well, let's try to understand what's happening here.

By definition, the number on the `k`

-th place in the `n`

-th row depicts in how many ways we can pick `k`

elements from a set of `n`

elements. But **what if instead, we pointed out the elements that we don't choose?** It may sound a bit vague, so why don't we show you an example.

Recall the scenario from the second section, where **we wanted to pick three movies to watch from a list of twenty**. But what if it's difficult to choose the three you want to see most? **Maybe it's easier to eliminate one by one those that you don't feel like watching**? Surely, if we then cross out seventeen of them, we'll be left with our choice of three. That is precisely what we described above - **we instead choose seventeen that we don't want to watch**. This, written using notation from Pascal's triangle formula in the first section, is:

`C(n,k) = C(n,n-k)`

,

which, for us, translates as **the number in the** `k`

**-th spot counting from the left is the same as the one on the** `k`

**-th when counting from the right for any row** `n`

.

## Example: binomial expansion

Mathematically speaking, the answer to "*What is Pascal's triangle?*" is just this: **binomial expansion**. Don't worry, we're not here to sound smug by using some fancy words and symbols when a simple explanation will do. **For everyones benefit, we'll show you through a real-life scenario how to answer this question, explaining how to use Pascal's triangle calculator along the way**.

**Say that your dog is having puppies**, and you know that there will be six of them, but you don't know their sexes. If we number the puppies in the order they come into this world, we can start thinking about the probability of what sex they will be. Surely **six boys are not as likely as, e.g., two boys and four girls**. That is because the two boys may come as the first two pups, or the last two, or the middle two, etc., and so there are far more combinations for that to happen.

Okay, now comes the tricky part. We'll try to convince you that **the pups can be described by a symbolic** `(x + y)⁶`

. To see this associate `x`

with "boy" and `y`

with "girl". Now look at the expansion:

`(x + y)⁶ = (x + y) * (x + y) * ... * (x + y)`

.

**How does each summand appear after we multiply out the above expression?** Well, it comes from taking one of the summands in each of the parentheses, i.e., by taking either `x`

or `y`

bracket after bracket. In our translation, that means **determining the sex of each of the six pups one by one**. This means that every summand of the form, say, `x² * y⁴`

, which corresponds to twice picking `x`

from inside the brackets and picking `y`

four times, translates to a litter of two boys and four girls.

Now let's look at **the expansion after the multiplication and reorganizing the similar monomials**:

`(x + y)⁶ = x⁶ + 6x⁵y + 15x⁴y² + 20x³y³+ 15x²y⁴ + 6xy⁵ + y⁶`

.

Compare it with **the sixth level of Pascal's triangle**, returned by Pascal's triangle calculator:

`1 6 15 20 15 6 1`

.

These numbers correspond to the coefficients in the expansion above. In other words, **the sixth (or** `n`

**-th in general) level of the triangle corresponds to the coefficients of** `(x + y)⁶`

**(respectively:** to the power n**) in their binomial expansion**. And this, as we saw with our dog scenario, translates further to answer some real-life problems.