Skip to main content
CalcMax

Pascal's Triangle Calculator

Range: 1 – 53

Result

1; 1, 1; 1, 2, 1; 1, 3, 3, 1; 1, 4, 6, 4, 1; 1, 5, 10, 10, 5, 1; 1, 6, 15, 20, 15, 6, 1

Triangle

Last row
1, 6, 15, 20, 15, 6, 1
Row sum
64

Pascal's triangle is a pyramid of numbers in which every entry is the sum of the two entries diagonally above it, with 1s down both edges. The first row is a single 1. The second is 1 and 1. The third is 1, 2, 1, because the 2 is the sum of the two 1s above it. The next is 1, 3, 3, 1, the next 1, 4, 6, 4, 1, and so on without end, each row one entry longer than the one before. The numbers in the nth row are the binomial coefficients, the numbers that appear when you multiply out (x + y) raised to the nth power, which is why row 2 reads 1, 2, 1 and expands to x² + 2xy + y². Two other things fall out of the same triangle. The sum of any row is a power of two — 1, 2, 4, 8, 16 — because each row is built from the one above it twice over, once shifted left and once shifted right. And reading the triangle along its shallow diagonals gives the Fibonacci numbers. This page prints the whole triangle up to the number of rows you ask for, repeats the last row on its own so you do not have to find it in a wall of digits, and gives the row sum separately. Rows are counted from 0, the way the coefficients are usually indexed, so asking for 7 rows gives rows 0 through 6 and finishes with 1, 6, 15, 20, 15, 6, 1.

The first seven rows, with each row's sum beside it

RowCoefficientsSum
011
11, 12
21, 2, 14
31, 3, 3, 18
41, 4, 6, 4, 116
51, 5, 10, 10, 5, 132
61, 6, 15, 20, 15, 6, 164

Read the sum column first: 1, 2, 4, 8, 16, 32, 64. Every row doubles the one before, which is worth understanding rather than memorising. Building a row means taking the row above and adding it to itself shifted one place, so its total is counted twice — once through the left edge and once through the right. That is also why the outer edges never change: the edge of a row has only one neighbour above it, so it can only ever inherit a 1. Now read the coefficients column against itself. Row 3 is 1, 3, 3, 1 and row 4 is 1, 4, 6, 4, 1: each entry is the sum of the two above it, and each row is symmetric because picking which items to take and picking which to leave are two descriptions of one choice. Row 6, the last in the table, is the row the default input finishes with, so the table and the result panel above it are showing the same numbers.

Formula

C(n, k) = C(n-1, k-1) + C(n-1, k); C(n, 0) = C(n, n) = 1; row sum = 2^n

n
The number of rows to print, counting the single 1 at the top as row 0. So n rows means rows 0 through n - 1, and the last row printed has n entries in it. The input runs from 1 to 53, and the ceiling is not about screen size — see the row sum entry below, which is the quantity that actually runs out of room first
k
The position within a row, counted from 0 at the left edge. Row n has entries at k = 0 through k = n, which is n + 1 numbers. The two edge positions are special: C(n, 0) and C(n, n) are both 1, and that is the pair of 1s running down the sides of the triangle. Everything strictly between them is the sum of two entries from the row above
C(n-1, k-1) + C(n-1, k)
The rule that builds the whole thing, and the one the page follows. The entry at position k of row n is the sum of the two entries above it — the one directly above-left and the one directly above-right, which is why the edges only ever see one number and stay at 1. This is done by addition rather than by the factorial formula, so every intermediate value is exact and the triangle on screen is literally the sequence of additions the page performed
C(n, k) = n! / (k! (n-k)!)
The other face of the same number: the binomial coefficient, which counts the ways to choose k items from n when order does not matter. It gives the same value as the addition rule and is what the numbers in the row mean when the triangle is used for counting rather than for algebra. The page does not compute with it, because the two would then be separate pieces of arithmetic that could drift apart
2^n
The sum of row n, and the reason the input stops where it does. Add a row up and you always get a power of two: row 0 sums to 1, row 1 to 2, row 2 to 4, and row 6 to 64. Doubling every row is why the sum leaves the exactly representable range before any single coefficient does — row 52 sums to 4503599627370496, row 53 to 9007199254740992, which is one past the last integer a double can hold exactly
1, 6, 15, 20, 15, 6, 1
Row 6 printed out, which is the last row of the default seven. Read it back against the row above it and every entry is a sum of two neighbours: 6 is 1 + 5, 15 is 5 + 10, 20 is 10 + 10, and then it mirrors. The row is symmetric about its middle, always, because choosing k items to keep and choosing n - k items to discard are the same choice counted twice

The triangle is the fastest way to expand a binomial by hand. To multiply out (x + y) to the sixth power you read row 6 straight off the page and write 1x⁶ + 6x⁵y + 15x⁴y² + 20x³y³ + 15x²y⁴ + 6xy⁵ + 1y⁶, with no multiplication of polynomials at all. A single coefficient is what you want when you only need one term, and the combinations page computes it directly from n and k without building the rows in between. Probability questions with two outcomes use the same numbers: the chance of exactly 4 heads in 10 tosses is C(10, 4) divided by 2¹⁰, and that 1024 in the denominator is row 10's sum. The triangle also answers counting questions that look unrelated — the number of paths across a grid from one corner to the opposite one, the number of ways to reach a particular square when you may only move right and down, and the count of subsets of a given size. When the question is what the numbers are rather than what they mean, this page prints them; when it is how many ways something can happen, the combinations page is the shorter route; and when the question is about the Fibonacci numbers that hide in the diagonals, the Fibonacci page covers that sequence directly.

Worked examples

  1. Seven rows, ending at 1 6 15 20 15 6 1

    1. Row 0 is 1, and row 1 is 1, 1 — the two edges of every row are always 1
    2. Row 2: 1 + 1 = 2 in the middle, giving 1, 2, 1
    3. Row 3: 1 + 2 = 3 twice, giving 1, 3, 3, 1; row 4: 1 + 3 = 4, 3 + 3 = 6, giving 1, 4, 6, 4, 1
    4. Row 5 and row 6 continue the same way, ending at 1, 6, 15, 20, 15, 6, 1
    5. Add row 6 across: 1 + 6 + 15 + 20 + 15 + 6 + 1 = 64, which is 2 to the sixth power

    The default input. Two things are worth checking against the screen. First, each number is the sum of the two above it: 15 is 5 + 10, 20 is 10 + 10, and the row is symmetric because 20 sits in the middle of seven entries and pairs up on either side of it. Second, the row sum doubles every time — 1, 2, 4, 8, 16, 32, 64 — so a reader who knows the row above sums to 32 can predict this one before adding it up. That doubling is the same fact as the two 1s on the edges: every row above contributes its whole total twice, once into the left half and once into the right.

  2. Four rows, the shortest useful triangle

    1. Row 0 is 1; row 1 is 1, 1
    2. Row 2 is 1, 2, 1, with the 2 coming from 1 + 1
    3. Row 3 is 1, 3, 3, 1, with each 3 coming from 1 + 2
    4. Sum the last row: 1 + 3 + 3 + 1 = 8, which is 2 cubed

    Row 3 is the last row here, and it is where the triangle becomes interesting: 1, 3, 3, 1 are the coefficients of (x + y)³, so x³ + 3x²y + 3xy² + y³ can be written down from this row without multiplying anything out. It is also the last row small enough to check by hand in a few seconds, which is why it is worth looking at before the longer ones. Notice that 4 rows means rows 0 through 3 — the number you type is a row count, not the index of the biggest row.

  3. One row, the trivial case

    1. Row 0 is a single 1, with nothing above it to add
    2. One row was asked for and one row is printed
    3. The row sum is 1, which is 2 to the zeroth power

    The smallest input the page accepts, and it is accepted rather than treated as empty. A triangle with one row is not degenerate — it is the base case every later row is built from. Reading it also confirms the indexing: asking for 1 row gives row 0, not row 1, which matters as soon as you compare the triangle against a binomial expansion. The sum being 1 rather than 0 is the same statement in arithmetic that the top of the triangle is a single 1.

Limitations

The number of rows must be a whole number from 1 to 53. The ceiling is there because every number printed has to be one a computer still represents exactly, and past that point two neighbouring integers collapse onto the same value — the printed digits still look perfectly ordinary, they just no longer stand for the number they claim to. The row sum is what gives out first: row 52 sums to 4503599627370496 and row 53 to 9007199254740992, one past the largest integer a double holds exactly. Individual coefficients would survive to row 56 — C(57, 28) is the first one past the line — but a triangle is printed a row at a time, so the sum decides. Zero rows is refused: an empty triangle prints nothing, so there is no answer to give. Fractions of a row are refused rather than rounded, since there is no such thing as two and a half rows. The rows come back as a flat line of numbers separated by commas, with rows separated by semicolons, and no thousands separators anywhere, so a large coefficient prints as 184756 rather than 184,756. On a wide triangle that means a long line to scroll. The reference table below shows the first seven rows rather than following your input, and no row is reachable by asking for it directly — the page always prints from the top down.

Frequently asked questions

What is Pascal's triangle used for?
Expanding binomials, mostly. The entries in row n are the coefficients you get when you multiply out (x + y) to the nth power, so row 6 lets you write down the seven terms of (x + y)⁶ immediately, without multiplying any polynomials together. The same numbers count combinations: C(n, k) is the entry at position k of row n, so they answer questions like how many ways there are to choose 4 people from 10. They also turn up in probability, where the chance of exactly 4 heads in 10 coin tosses is C(10, 4) out of 2¹⁰ — and that 1024 is the sum of row 10. Grid path counting uses them too: the number of routes across a grid from one corner to the opposite one, moving only right and down, is a triangle entry.
Why does the input stop at 53 rows?
Because the row sum stops being an integer a computer can represent exactly. Row 52 sums to 4503599627370496 and row 53 to 9007199254740992, and that second number is one past the largest value a double-precision number holds exactly. Past that point two neighbouring integers become the same value, so the printed digits still look ordinary while no longer standing for the number they claim to. The individual coefficients would last longer — the first one past the line is C(57, 28), in row 57 — but a triangle is printed a row at a time, so the sum is what decides. Printing a row whose total is wrong and whose individual entries are right would be a confusing thing to ship.
Why does the last row get printed twice?
Because on a large triangle the last row is the only part most readers want, and finding it inside a long line of digits is work. Ask for 40 rows and the triangle output is a wall of numbers where the row you care about is at the far right; the last row output is that same row on its own, in a readable size. Both come from the same computation, so they cannot disagree. The row sum is printed a third time for the same reason — it is a single number that answers a question the row of digits does not answer at a glance.
Do rows start at 0 or at 1?
At 0, which is the convention the coefficients are usually indexed with. C(n, k) means the entry at position k of row n, so the top single 1 is row 0 and asking for 7 rows gives you rows 0 through 6, finishing with 1, 6, 15, 20, 15, 6, 1 — seven numbers, because row n always has n + 1 entries. This matters when you compare the triangle against a binomial expansion: the row of coefficients for (x + y)⁶ is row 6, not row 7. The count you type is a number of rows, not the index of the largest row.
What is the sum of a row, and why is it always a power of two?
Add up any row and you get 2 raised to that row's index: row 0 gives 1, row 6 gives 64, row 10 gives 1024. The reason is the rule that builds the triangle. Each row is made from the row above it, added to itself shifted one place, so every number in the row above is counted twice in the row below — once on the left side and once on the right. Doubling the total every time gives powers of two. The same fact read another way: the sum of row n counts every subset of an n-element set, and a set with n elements has 2ⁿ subsets. That is why the 1024 on the bottom of a ten-coin-toss probability comes straight out of row 10.
Where do the Fibonacci numbers come from in this triangle?
From the shallow diagonals. Add the numbers along a line that runs up and to the left — for instance 1, then 4, then 3 — and the running totals come out 1, 1, 2, 3, 5, 8, 13. Those are the Fibonacci numbers, where each one is the sum of the two before it. The reason is that each entry in a diagonal is itself built from the two entries above it, one of which lies on the same diagonal and one on the next one along, so the diagonals inherit the Fibonacci recurrence directly. The Fibonacci calculator covers that sequence on its own if you want to follow it further.

References

Related calculators