Pascal's Triangle Generator
Generate Pascal's triangle up to row 30 with exact values, highlight any row and see it turned into a binomial expansion such as (x + y)⁶ or (2x − 3)⁵. Shade the odd numbers to reveal the Sierpinski pattern.
Up to row 30
Its binomial expansion is shown
e.g. 2 and −3 for (2x − 3y)ⁿ
How to use the Pascal's Triangle Generator
- Choose how many rows to show (0 to 30).
- Pick the row to highlight; its expansion is calculated.
- Set the terms and their coefficients, for example x and y, or 2 and −3 for (2x − 3)ⁿ.
- Press Generate to draw the triangle and expand the binomial.
- Tick the shading option to see the odd-number pattern, or copy the results.
Rows 0 to 10 and their expansions
| n | Row n | Sum (2ⁿ) | (x + y)ⁿ |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 1 | 1 1 | 2 | x + y |
| 2 | 1 2 1 | 4 | x² + 2xy + y² |
| 3 | 1 3 3 1 | 8 | x³ + 3x²y + 3xy² + y³ |
| 4 | 1 4 6 4 1 | 16 | x⁴ + 4x³y + 6x²y² + 4xy³ + y⁴ |
| 5 | 1 5 10 10 5 1 | 32 | x⁵ + 5x⁴y + 10x³y² + 10x²y³ + 5xy⁴ + y⁵ |
| 6 | 1 6 15 20 15 6 1 | 64 | x⁶ + 6x⁵y + 15x⁴y² + 20x³y³ + … |
| 7 | 1 7 21 35 35 21 7 1 | 128 | x⁷ + 7x⁶y + 21x⁵y² + 35x⁴y³ + … |
| 8 | 1 8 28 56 70 56 28 8 1 | 256 | x⁸ + 8x⁷y + 28x⁶y² + … |
| 9 | 1 9 36 84 126 126 84 36 9 1 | 512 | x⁹ + 9x⁸y + 36x⁷y² + … |
| 10 | 1 10 45 120 210 252 210 120 45 10 1 | 1,024 | x¹⁰ + 10x⁹y + 45x⁸y² + … |
Key formulas
- Pascal's rule: C(n, k) = C(n − 1, k − 1) + C(n − 1, k)
- Entry formula: C(n, k) = n! / (k!(n − k)!)
- Symmetry: C(n, k) = C(n, n − k), so every row reads the same both ways
- Binomial theorem: (a + b)ⁿ = Σk=0n C(n, k) aⁿ⁻ᵏ bᵏ
- Row sum: Σ C(n, k) = 2ⁿ; hockey stick: C(r, r) + C(r + 1, r) + … + C(n, r) = C(n + 1, r + 1)
The largest number in row 30 is C(30, 15) = 155,117,520, and row 30 sums to 2³⁰ = 1,073,741,824.
Frequently asked questions
How is Pascal's triangle built?
Start with 1 at the top (row 0). Each row begins and ends with 1, and every other entry is the sum of the two numbers directly above it. Row 4 is 1 4 6 4 1 because 1 + 3 = 4 and 3 + 3 = 6.
What is the formula for an entry?
The k-th entry of row n (both counted from 0) is the binomial coefficient C(n, k) = n! / (k!(n − k)!), the number of ways to choose k items from n. For example C(6, 2) = 15.
How does Pascal's triangle help expand (x + y)ⁿ?
By the binomial theorem, (x + y)ⁿ = Σ C(n, k) xⁿ⁻ᵏ yᵏ, so row n gives the coefficients. Row 3 is 1 3 3 1, so (x + y)³ = x³ + 3x²y + 3xy² + y³.
What if the terms have coefficients, like (2x − 3)⁵?
Multiply each binomial coefficient by the powers of the term coefficients: the k-th term is C(n, k)·(2x)⁵⁻ᵏ·(−3)ᵏ. The generator does this for you and keeps the numbers exact.
What is the sum of a row?
The entries of row n add up to 2ⁿ, because choosing any subset of n items gives 2ⁿ possibilities. Row 10 sums to 1,024.
Why does shading odd numbers make a Sierpinski triangle?
Working modulo 2, each entry is the XOR of the two above it, which produces the self-similar Sierpinski pattern. By Lucas' theorem, C(n, k) is odd exactly when every binary digit of k is at most the matching digit of n.
What other patterns are hidden in Pascal's triangle?
The diagonals contain the counting numbers, the triangular numbers (1, 3, 6, 10, …) and the tetrahedral numbers; the shallow diagonals add up to Fibonacci numbers; and rows 0–4 read as powers of 11 (1, 11, 121, 1331, 14641).