🏆 US-Registered Digital Marketing Agency
Advertisement
Advertisement
EDUCATION

Pascal's Triangle Generator — rows, entries and patterns

Print Pascal's triangle to any number of rows, read off any single entry exactly, and colour the cells to reveal the hidden divisibility patterns.

Rows are numbered from 0, so 9 rows runs from row 0 up to row 8. Above 16 rows the numbers are hidden and the pattern view takes over.
Shading a cell when its value is not divisible by the chosen number exposes a fractal structure that is invisible in the digits.
Entry C(n, k)
 
0
Row sum 2ⁿ
0
Largest entry in row
0
Entries in row
0
Digits in the entry
Tip: rows and entries are both numbered from zero. The 1, 4, 6, 4, 1 row is row 4, and the 6 in the middle of it is entry k = 2, not the third entry.
Advertisement

A Pascal's triangle generator builds the triangular array in which every entry is the sum of the two entries directly above it, starting from a single 1 at the apex. That one rule generates the binomial coefficients, the coefficients of every expansion of (a + b)n, the counts behind every combination problem, and — when you colour the cells by divisibility — a fractal. This tool prints the triangle, reads off any single entry exactly, and shades the cells to make the patterns visible.

Arb Digital built this page around exact arithmetic. Once you pass row 56 or so, the middle entries exceed the largest whole number a browser can hold in an ordinary numeric variable, and most online generators silently start returning approximations that end in zeros. This one computes with arbitrary-precision integers throughout, so the entry it shows for row 200 is the exact value, digit for digit.

What This Pascal's Triangle Generator Does

Set the number of rows and the triangle is built row by row from the addition rule, then drawn to scale. Set a row number n and an entry number k and the tool returns C(n, k) as the headline result, together with that row's total, its largest entry, how many entries it holds and how many digits your chosen value has. The colouring control shades cells according to whether their value divides by 2, 3 or 5, or according to their relative size within their own row.

It is deliberately different from our binomial coefficient calculator, which computes one value of "n choose k" and stops there. This page shows the whole structure the coefficients live in, which is what makes the recurrence, the symmetry and the divisibility patterns visible. For counting problems where order matters rather than combinations, the permutation calculator is the right page, and for the raw factorials underneath both, use the factorial calculator.

How to Use It

  1. Choose how many rows to print. Nine rows is enough to see the pattern. Sixteen is about the limit for readable numbers on a phone; beyond that the tool switches to a pattern view.
  2. Set n and k to look up an entry. Both count from zero. Row 8, entry 3 is 56 — the fourth number along in the ninth row printed.
  3. Watch the highlighted cell. If the row you asked for is inside the printed range, that entry is outlined in the drawing, so you can see where it sits.
  4. Turn on a colour rule. Divisibility by 2 produces the Sierpinski triangle. Divisibility by 3 and by 5 produce their own, differently shaped fractals.
  5. Push n higher than the printed rows. The lookup works up to row 400 regardless of how many rows are drawn, and stays exact the whole way.

The Rule: How Each Entry Is Calculated

The construction rule is one line: the outer entries of every row are 1, and every interior entry is the sum of the two entries above it. Written formally that is C(n, k) = C(n − 1, k − 1) + C(n − 1, k), which is known as Pascal's rule and is set out in the DLMF section on lattice paths and binomial coefficients.

There is also a closed form that skips straight to any entry without building the rows above it: C(n, k) = n! ÷ (k! × (n − k)!). For row 8, entry 3, that is 40320 ÷ (6 × 120) = 40320 ÷ 720 = 56. The tool uses a multiplicative version of the same formula — multiply by n, then n − 1, and so on, dividing as it goes — because that keeps the intermediate values far smaller than computing three separate factorials and avoids overflow entirely.

The row total follows from the binomial theorem. Setting a = b = 1 in (a + b)n makes every term in the expansion equal to its coefficient, so the entries of row n must add to 2n. Row 8 sums to 256, and you can check it: 1 + 8 + 28 + 56 + 70 + 56 + 28 + 8 + 1 = 256.

Advertisement

Why Colouring by Parity Produces a Fractal

Shade every odd entry and leave every even one blank, and the Sierpinski triangle appears — a shape defined by removing the middle quarter of a triangle, then the middle quarter of each remaining piece, forever. Nothing in the addition rule mentions triangles or self-similarity, so the pattern feels like a coincidence. It is not.

The reason sits in the addition itself. Working modulo 2, odd plus odd is even, odd plus even is odd, and even plus even is even — which is exactly the exclusive-or rule. That makes the parity of the triangle a cellular automaton, and the automaton's state after 2m steps reproduces its own starting shape at double the size. Kummer's theorem sharpens this: the power of a prime p dividing C(n, k) equals the number of carries when k and n − k are added in base p. C(n, k) is odd exactly when adding k and n − k in binary produces no carries at all, and the set of such pairs is self-similar by construction.

Switch the colouring to 3 or 5 and you get a different fractal each time, because the carry rule now operates in base 3 or base 5. The triangular holes become larger and the surviving pattern denser. If you want to see the base arithmetic behind that directly, our number base converter shows the binary and ternary representations, and the prime factorization calculator shows which primes actually divide a given entry.

The Diagonals Are Number Sequences You Already Know

Read the triangle along its diagonals rather than its rows and it stops being about binomial coefficients. The first diagonal is all 1s. The second is 1, 2, 3, 4, 5 — the counting numbers. The third is 1, 3, 6, 10, 15 — the triangular numbers, which count how many objects fit in a triangular arrangement. The fourth is 1, 4, 10, 20, 35 — the tetrahedral numbers, the same idea in three dimensions.

The Fibonacci numbers hide there too, but along the shallow diagonals rather than the steep ones. Add the entries along each shallow diagonal — 1, then 1, then 1 + 1, then 1 + 2, then 1 + 3 + 1 — and you get 1, 1, 2, 3, 5, 8. Our Fibonacci calculator generates the sequence directly if you want to check the sums against it.

The hockey stick identity is the most useful of these diagonal facts in practice: the sum of any run of entries down a diagonal, starting from the edge, equals the entry one step down and one step across from where the run ends. 1 + 3 + 6 + 10 = 20, and 20 sits diagonally below the 10. It turns a summation into a single lookup.

Symmetry, and the Fastest Way to Compute an Entry

Every row reads the same forwards as backwards, because C(n, k) = C(n, n − k). Choosing which 3 of 8 items to take is the same act as choosing which 5 to leave, so the two counts must match. That symmetry is the single most useful computational shortcut available: to compute C(200, 197), compute C(200, 3) instead, which is three multiplications rather than a hundred and ninety-seven.

This tool applies that shortcut automatically, replacing k with n − k whenever k is in the larger half. Combined with the multiplicative formula it means even row 400 returns instantly. The largest entry in any row is always the central one, C(n, n/2) for even n and the two equal middle entries for odd n, and it grows roughly like 2n divided by the square root of n — which is why the digit count in the grid climbs so quickly as you raise n.

Where the Triangle Is Actually Used

The immediate use is expanding brackets. The coefficients of (a + b)5 are row 5 — 1, 5, 10, 10, 5, 1 — so the expansion is a⁵ + 5a⁴b + 10a³b² + 10a²b³ + 5ab⁴ + b⁵ with no multiplication of brackets required.

The second use is probability. Flip a fair coin n times and the number of ways to get exactly k heads is C(n, k), so row n divided by 2n is the entire probability distribution for that experiment. Row 8 tells you there are 70 ways out of 256 to get exactly four heads in eight flips, which is about 27 percent — noticeably less than most people guess, because the single most likely outcome is still far from certain. Our binomial distribution calculator extends that to unfair coins, and the probability calculator handles the combining rules.

The third use is as a bridge to the normal distribution. Plot any high row as a bar chart and the shape is a bell curve, which is the central limit theorem appearing in its most concrete possible form: the sum of many independent coin flips is approximately normal, and the triangle is that statement written in integers. MIT's Principles of Discrete Applied Mathematics course develops the counting and probability sides of this together.

Need more free maths tools?

Arb Digital publishes hundreds of free calculators covering combinatorics, algebra, statistics and geometry — all free to use, with no sign-up and no limit on how often you run them.

Browse All Free Tools Suggest a Tool

Common Mistakes to Avoid

  • Counting rows from one. The apex is row 0. The row 1, 4, 6, 4, 1 is row 4, and it has five entries, not four.
  • Counting entries from one. Entry k also starts at zero, so the leading 1 in every row is k = 0.
  • Confusing C(n, k) with a permutation count. Combinations ignore order. If the order of the chosen items matters, the count is larger by a factor of k factorial.
  • Trusting a generator past row 56. Ordinary floating-point arithmetic loses exactness there, and the tell-tale sign is a large entry ending in an implausible run of zeros.
  • Reading a coloured pattern as data. The Sierpinski shading shows divisibility only. A shaded cell says the entry is odd, not that it is large.

Related Free Tools From Arb Digital

Use the binomial coefficient calculator for a single value with its working, the permutation calculator when order matters, the factorial calculator for the factorials underneath, the binomial distribution calculator to turn a row into probabilities, and the Fibonacci calculator to check the shallow diagonals. More are listed in the free tools hub.

Frequently Asked Questions

How is Pascal's triangle built?

Start with a single one at the top. Every row begins and ends with a one, and every other entry is the sum of the two entries immediately above it. That single addition rule generates the entire triangle and every binomial coefficient in it.

Which row is 1, 4, 6, 4, 1?

That is row four, because rows are numbered from zero starting at the apex. It has five entries, numbered k equals zero through four, and it gives the coefficients of the expansion of a plus b raised to the fourth power.

What do the entries in a row add up to?

Row n adds to two raised to the power n. Setting both variables to one in the binomial theorem makes every term equal to its coefficient, so the sum of the coefficients has to equal two to the n. Row eight therefore sums to two hundred and fifty six.

Why does colouring the odd numbers make a Sierpinski triangle?

Because addition modulo two is the exclusive-or rule, which makes the parity pattern a self-similar cellular automaton. Kummer's theorem states it precisely: an entry is odd exactly when adding k and n minus k in binary produces no carries, and that condition is self-similar at every scale.

Where are the triangular numbers in Pascal's triangle?

Along the third diagonal, reading one, three, six, ten, fifteen. The second diagonal holds the counting numbers and the fourth holds the tetrahedral numbers. The Fibonacci numbers appear as the sums along the shallow diagonals rather than the steep ones.

What is the hockey stick identity?

The sum of a run of entries down a diagonal, starting at the edge of the triangle, equals the single entry one row below and one place across from the end of the run. One plus three plus six plus ten equals twenty, and twenty sits diagonally below the ten.

Can this generator handle very large rows?

Yes. Entries are computed with arbitrary-precision integers rather than ordinary floating-point numbers, so lookups stay exact up to row four hundred. Tools that use ordinary numbers lose exactness somewhere around row fifty-six, and the symptom is a large value ending in a run of zeros.

How does Pascal's triangle relate to coin flips?

Row n counts the ways to get each possible number of heads in n flips of a fair coin. Divide the row by two to the n and you have the whole probability distribution. Row eight says seventy of the two hundred and fifty six equally likely outcomes give exactly four heads.

This generator is provided for study and for checking your own working. It is not a substitute for showing the construction steps your course or assessment requires.

Advertisement
Advertisement

Take it further