DigitHelm

Pascal's Triangle Calculator

Generate Pascal's triangle up to any row and expand (a + b)ⁿ using the binomial theorem. Shows all coefficients and the full polynomial expansion.

Generate Pascal's Triangle

Binomial Coefficient C(n, k)

Find any entry in Pascal's triangle, supports n up to 200 with exact integer arithmetic.

Binomial Expansion (a + b)ⁿ

What Is the Pascal's Triangle Calculator?

This Pascal's triangle calculator generates up to 30 rows with colour-coded intensity, looks up any specific binomial coefficient C(n,k) using exact BigInt arithmetic (n up to 200), and expands (a+b)^n with custom variable names up to n = 20.

  • 30-row triangle: Full Pascal's triangle with row sums displayed and intensity-coded cells.
  • C(n,k) lookup: Find any binomial coefficient exactly, supports n up to 200 with BigInt precision.
  • Binomial expansion: Expand (a+b)^n up to n=20 with custom a and b variable names or numbers.
  • Row properties: Row n sums to 2ⁿ; displayed in real-time alongside each row.
  • Colour intensity: Cells are shaded proportionally to their value within the row for visual pattern recognition.

Formula

C(n,k) = n! / (k! × (n−k)!)  ·  (a+b)ⁿ = Σₖ C(n,k) aⁿ⁻ᵏ bᵏ
Row n sum = 2ⁿ  ·  C(n,k) = C(n−1,k−1) + C(n−1,k)  (Pascal's rule)
Row nEntries C(n,k)Row sum
011 = 2^0
11 12 = 2^1
21 2 14 = 2^2
31 3 3 18 = 2^3
41 4 6 4 116 = 2^4
51 5 10 10 5 132 = 2^5

How to Use

  1. 1Enter a number of rows (1–30) and click Generate to view the triangle.
  2. 2To find a specific coefficient, enter n (row) and k (position) in the C(n,k) lookup section and click Look Up.
  3. 3For binomial expansion, enter the variable names (or numbers) for a and b, the exponent n, and click Expand.
  4. 4Click Clear to reset all three panels.

Example Calculation

Binomial expansion: (x + 2)⁴

a = x, b = 2, n = 4 (x + 2)⁴ = C(4,0)x⁴ + C(4,1)x³·2 + C(4,2)x²·4 + C(4,3)x·8 + C(4,4)·16 = x⁴ + 8x³ + 24x² + 32x + 16 Enter: a = x, b = 2, exponent = 4 Result: x⁴ + 8·x³·2 + 6·x²·4 + 4·x·8 + 16

C(n,k) exact lookup

The C(n,k) panel uses BigInt arithmetic and supports n up to 200. For example, C(100, 50) = 100891344545564193334812497256. JavaScript's regular numbers cannot represent this exactly, BigInt ensures every digit is correct.

Understanding Pascal's Triangle

Properties of Pascal's Triangle

Pascal's triangle is an infinite triangular array where each entry is the sum of the two entries directly above it. Each entry in row n, position k is the binomial coefficient C(n,k) = n! / (k!(n−k)!). This simple construction encodes dozens of mathematical patterns.

  • Row sums: Row n sums to 2ⁿ (each row element is a power-of-2 partition)
  • Fibonacci: Diagonal sums give Fibonacci numbers 1, 1, 2, 3, 5, 8, 13, …
  • Powers of 11: Row n = digits of 11ⁿ (for small n): row 2 = 121 = 11², row 3 = 1331 = 11³
  • Sierpiński triangle: Colour odd entries to reveal a fractal pattern
  • Triangular numbers: The third diagonal is 1, 3, 6, 10, 15, … (n(n+1)/2)
  • Hockey stick identity: C(r,r) + C(r+1,r) + … + C(n,r) = C(n+1,r+1)

Binomial Theorem

The binomial theorem states that (a + b)ⁿ = Σ C(n,k) aⁿ⁻ᵏ bᵏ (k from 0 to n). The coefficients in the expansion are exactly the n-th row of Pascal's triangle. This is used throughout algebra, probability (binomial distribution), and combinatorics.

(a + b)⁵ = a⁵ + 5a⁴b + 10a³b² + 10a²b³ + 5ab⁴ + b⁵ Coefficients: 1 5 10 10 5 1 (row 5 of Pascal's triangle)

Binomial Coefficients in Probability

C(n,k) counts the number of ways to choose k items from n without regard to order. In probability, if each trial succeeds with probability p, the binomial distribution gives P(X = k) = C(n,k) · pᵏ · (1−p)^(n−k). Pascal's triangle provides all the coefficients needed for this calculation directly.

Frequently Asked Questions

How is each entry in Pascal's triangle calculated?

Each entry is the sum of the two entries directly above it. The edges of the triangle are always 1. In formula form: C(n,k) = C(n−1,k−1) + C(n−1,k). This is Pascal's rule and it means you only need the previous row to compute the next.

Row 4: 1 4 6 4 1 Row 5: 1 5 10 10 5 1 ↑ ↑ 1+4=5, 4+6=10, etc.

What is a binomial coefficient C(n,k)?

C(n,k) (also written nCk or "n choose k") counts the number of ways to choose k items from n items without repetition and without regard to order.

C(5,2) = 5! / (2! × 3!) = 120 / (2 × 6) = 10 = ways to choose 2 items from 5

In Pascal's triangle, C(n,k) is the entry in row n (starting at 0), position k (starting at 0).

Why does each row sum to a power of 2?

Setting a = b = 1 in the binomial theorem: (1 + 1)ⁿ = Σ C(n,k) · 1ⁿ⁻ᵏ · 1ᵏ = Σ C(n,k) = 2ⁿ. Every row sum is the total number of subsets of an n-element set, and there are always 2ⁿ subsets (including the empty set).

How is Pascal's triangle used in probability?

In the binomial distribution, the probability of exactly k successes in n trials is P(X=k) = C(n,k) · pᵏ · (1−p)^(n−k). The C(n,k) coefficients come directly from Pascal's triangle. For example, flipping a fair coin 5 times:

P(exactly 2 heads) = C(5,2) × (0.5)² × (0.5)³ = 10 × 0.25 × 0.125 = 0.3125

What is the Sierpiński triangle connection?

If you colour the odd entries of Pascal's triangle one colour and even entries another, the result is the Sierpiński triangle, a famous fractal with self-similar structure at every scale. This is because C(n,k) mod 2 follows a recursive pattern determined by Lucas' theorem: C(n,k) is odd if and only if each bit of k is ≤ the corresponding bit of n in binary.

How large can n be for the C(n,k) lookup?

The C(n,k) lookup supports n up to 200. It uses JavaScript BigInt arithmetic, which supports integers of arbitrary size, no floating-point precision loss. For reference:

  • C(20, 10) = 184,756
  • C(50, 25) = 126,410,606,437,752
  • C(100, 50) = 100,891,344,545,564,193,334,812,497,256
  • C(200, 100) = an integer with 58 digits

JavaScript's regular number type (IEEE 754 double) can only represent integers exactly up to 2⁵³ ≈ 9×10¹⁵. Beyond that, BigInt is required for exact results.

What is the hockey stick identity?

The hockey stick identity states: C(r,r) + C(r+1,r) + C(r+2,r) + … + C(n,r) = C(n+1,r+1). Reading along a diagonal starting from a 1 at the edge and summing entries, the total equals the entry one step down and one step right, forming a hockey stick shape in the triangle.

r=2: C(2,2)+C(3,2)+C(4,2)+C(5,2) = 1+3+6+10 = 20 = C(6,3)

Related Calculators