Pascal's Triangle Generator
Generate Pascal's triangle up to N rows. Highlight even/odd patterns, view binomial coefficients, and click any number to see its nCr value.
Pascal's triangle is a triangular array where each number is the sum of the two numbers directly above it. Row 0 is just 1. Row 1 is 1, 1. Row 2 is 1, 2, 1. Each entry equals the binomial coefficient C(n, r) - the number of ways to choose r items from n. This tool generates up to 30 rows and makes every entry clickable and interactive.
About Pascal's Triangle Generator
How Is Pascal's Triangle Constructed?
Start with a 1 at the top. Each row begins and ends with 1. Every other entry is the sum of the two entries directly above it. Here are the first 8 rows:
| Row (n) | Entries | Row Sum |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 1, 1 | 2 |
| 2 | 1, 2, 1 | 4 |
| 3 | 1, 3, 3, 1 | 8 |
| 4 | 1, 4, 6, 4, 1 | 16 |
| 5 | 1, 5, 10, 10, 5, 1 | 32 |
| 6 | 1, 6, 15, 20, 15, 6, 1 | 64 |
| 7 | 1, 7, 21, 35, 35, 21, 7, 1 | 128 |
Notice the row sums: 1, 2, 4, 8, 16, 32, 64, 128 - each is a power of 2. The sum of row n is always 2^n. This follows from the binomial theorem with a = b = 1: (1+1)^n = 2^n.
Binomial Coefficients - the C(n, r) Connection
The entry at row n, position r (counting from 0) equals the binomial coefficient C(n, r), calculated as n! / (r! x (n-r)!). Click any number in the triangle and this tool shows the full formula and calculation.
Worked example: What is the entry at row 6, position 2?
C(6, 2) = 6! / (2! x 4!) = 720 / (2 x 24) = 720 / 48 = 15
Check the table above - row 6 reads 1, 6, 15, 20, 15, 6, 1, and position 2 is indeed 15.
| Property | Formula | Meaning |
|---|---|---|
| Symmetry | C(n, r) = C(n, n-r) | Choosing r items is the same as leaving out n-r items |
| Edges are 1 | C(n, 0) = C(n, n) = 1 | One way to choose nothing or everything |
| Pascal's rule | C(n, r) = C(n-1, r-1) + C(n-1, r) | Each entry = sum of two above it |
| Row sum | Sum of row n = 2^n | Total subsets of an n-element set |
| Alternating sum | C(n,0) - C(n,1) + C(n,2) - ... = 0 | For n > 0, even and odd subsets balance |
For computing individual combinations and permutations, the Permutations and Combinations Calculator handles larger values directly.
How Is Pascal's Triangle Used for Binomial Expansion?
The binomial theorem says (a + b)^n = sum of C(n, r) x a^(n-r) x b^r for r = 0 to n. The coefficients come straight from row n of Pascal's triangle.
Example: Expand (x + y)^4. Row 4 gives coefficients 1, 4, 6, 4, 1:
(x + y)^4 = x^4 + 4x^3y + 6x^2y^2 + 4xy^3 + y^4
| Expression | Row | Expansion |
|---|---|---|
| (a+b)^0 | 0 | 1 |
| (a+b)^1 | 1 | a + b |
| (a+b)^2 | 2 | a^2 + 2ab + b^2 |
| (a+b)^3 | 3 | a^3 + 3a^2b + 3ab^2 + b^3 |
| (a+b)^4 | 4 | a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4 |
| (a+b)^5 | 5 | a^5 + 5a^4b + 10a^3b^2 + 10a^2b^3 + 5ab^4 + b^5 |
This is why Pascal's triangle is taught alongside algebra - it gives you the coefficients for any power of a binomial without multiplying everything out by hand.
Patterns Hidden in the Triangle
Pascal's triangle contains a surprising number of patterns. Use the highlight buttons in this tool to see them visually.
| Pattern | Where to Find It | What You See |
|---|---|---|
| Natural numbers | Second diagonal (positions 1) | 1, 2, 3, 4, 5, 6, 7... |
| Triangular numbers | Third diagonal (positions 2) | 1, 3, 6, 10, 15, 21... |
| Tetrahedral numbers | Fourth diagonal (positions 3) | 1, 4, 10, 20, 35... |
| Fibonacci numbers | Shallow diagonals (sum entries along) | 1, 1, 2, 3, 5, 8, 13... |
| Powers of 2 | Row sums | 1, 2, 4, 8, 16, 32... |
| Powers of 11 | Rows (concatenate single digits) | 1, 11, 121, 1331, 14641... |
| Sierpinski triangle | Colour odd entries | Fractal triangular pattern |
| Catalan numbers | C(2n,n) / (n+1) | 1, 1, 2, 5, 14, 42, 132... |
The Fibonacci diagonal is one of the most elegant: sum the entries along each shallow diagonal going from the left edge upward to the right, and you get the Fibonacci sequence. For example, in the diagonal starting at row 5 position 0: C(5,0) + C(4,1) + C(3,2) = 1 + 4 + 3 = 8 = F(6). Explore the Fibonacci Generator to study the sequence directly.
The Sierpinski Triangle Fractal
Colour every odd entry one shade and every even entry another. What emerges is the Sierpinski triangle - a self-similar fractal that appears at every scale as you add more rows. This happens because C(n, r) is odd exactly when every bit of r is also a bit of n (in binary). The pattern becomes more dramatic as you generate more rows. At 16 rows you can see the first clear nesting; at 32 rows the fractal structure is unmistakable.
Pascal's Triangle in Probability
If you flip a fair coin n times, the number of ways to get exactly r heads is C(n, r). The probability of exactly r heads in n flips is C(n, r) / 2^n. Row n of Pascal's triangle gives the numerators, and 2^n (the row sum) gives the denominator.
Example: Flip a coin 5 times. Row 5 is 1, 5, 10, 10, 5, 1. Total outcomes = 32.
| Heads | Ways C(5,r) | Probability |
|---|---|---|
| 0 | 1 | 1/32 = 3.1% |
| 1 | 5 | 5/32 = 15.6% |
| 2 | 10 | 10/32 = 31.3% |
| 3 | 10 | 10/32 = 31.3% |
| 4 | 5 | 5/32 = 15.6% |
| 5 | 1 | 1/32 = 3.1% |
This is the binomial distribution in its simplest form. For applied probability problems, the Probability Calculator handles compound events and conditional probability.
Hockey Stick Identity
Pick any entry on the left edge (a 1), move diagonally down-right through several entries, then turn the corner one step straight down. The entry at the corner equals the sum of all the diagonal entries above it. This forms a hockey stick shape in the triangle.
C(r,r) + C(r+1,r) + C(r+2,r) + ... + C(n,r) = C(n+1, r+1)
Example: C(2,2) + C(3,2) + C(4,2) + C(5,2) = 1 + 3 + 6 + 10 = 20 = C(6,3).
Computing Large Binomial Coefficients
| C(n, r) | Value | Context |
|---|---|---|
| C(10, 3) | 120 | Ways to pick 3 from 10 |
| C(20, 10) | 184,756 | Middle of row 20 |
| C(30, 15) | 155,117,520 | Middle of row 30 |
| C(52, 5) | 2,598,960 | Possible 5-card poker hands |
| C(49, 6) | 13,983,816 | UK Lotto combinations |
| C(100, 50) | ~1.009 x 10^29 | Largest entry in row 100 |
The middle entry of each row is always the largest, and it grows roughly as 4^n / sqrt(pi x n) for large n. This rapid growth is why the numbers in Pascal's triangle get very large very quickly.
A Short History of the Triangle
Pascal's triangle is named after French mathematician Blaise Pascal, who published his Traité du triangle arithmétique in 1665, but the pattern was known centuries earlier around the world. Indian mathematician Pingala described it around 200 BCE in his work on Sanskrit prosody. Persian mathematician Al-Karaji wrote about it in the 10th century, and Omar Khayyam studied its properties around 1100 CE - it is still called Khayyam's triangle in Iran. In China, Jia Xian described it in the 11th century and Zhu Shijie recorded the first eight rows in his 1303 work Jade Mirror of the Four Unknowns, where it is known as Yang Hui's triangle. Pascal's contribution was connecting the triangle to probability theory through his correspondence with Pierre de Fermat on games of chance - a foundation the field of probability was built on.
| Mathematician | Year | Region |
|---|---|---|
| Pingala | c. 200 BCE | India |
| Al-Karaji | c. 1000 CE | Persia |
| Omar Khayyam | c. 1100 CE | Persia |
| Jia Xian / Yang Hui | c. 1050-1261 CE | China |
| Zhu Shijie | 1303 CE | China |
| Blaise Pascal | 1665 CE | France |
How Does This Tool Compute Large Entries?
Computing C(n, r) naively as n! / (r! x (n-r)!) overflows JavaScript numbers quickly, since 21! already exceeds 2^53. This tool uses the multiplicative formula C(n, r) = product of (n-i)/(i+1) for i from 0 to r-1, with the smaller of r and n-r chosen as the loop bound thanks to the symmetry rule. That keeps intermediate values small enough to survive within JavaScript's double-precision floats up to about row 30, where the largest entry C(30, 15) = 155,117,520 is still well inside the safe integer range of 2^53 - 1 (roughly 9.007 x 10^15). Beyond that, exact integer arithmetic would require BigInt - which is why the tool caps at 30 rows. For combinatorics work at larger n, a symbolic math system like Wolfram Alpha or a language with arbitrary-precision integers (Python, Haskell) is the right choice.
The triangle also builds entire rows recursively via Pascal's rule, C(n, r) = C(n-1, r-1) + C(n-1, r). That approach is useful when you need every entry in a row, because each entry is computed from adjacent entries already known - no factorials or divisions required. Most textbook implementations use this approach for teaching, while the multiplicative formula is preferred when you need a single binomial coefficient quickly. For related counting problems, the Factorial Calculator and Probability Calculator pair well with this tool.
Common Mistakes When Using Pascal's Triangle
The most frequent error is counting rows and positions starting from 1 instead of 0. The top row with a single 1 is row 0, and the first entry of every row is position 0. Mislabelling leads to off-by-one errors in every binomial coefficient lookup. Another common mistake is forgetting that C(n, r) and C(n, n-r) are equal - students often compute both instead of using symmetry to halve the work. Finally, the "powers of 11" pattern breaks at row 5 because the entries become two digits (1, 5, 10, 10, 5, 1) and carries have to be performed to recover 11^5 = 161,051. The pattern still holds if you interpret the row as a polynomial in 10 with no carries rather than as a concatenated integer.
Sources
- Encyclopaedia Britannica - Pascal's triangle
- Wolfram MathWorld - Pascal's Triangle
- Wolfram MathWorld - Binomial Coefficient
- MacTutor History of Mathematics - Blaise Pascal
- OEIS A007318 - Pascal's triangle read by rows
- Wolfram MathWorld - Sierpinski Sieve
All rendering runs in your browser. No data is sent to any server.
Frequently Asked Questions
What is Pascal's triangle?
Pascal's triangle is a triangular array where each number is the sum of the two numbers directly above it. Row 0 is just 1, row 1 is 1 1, row 2 is 1 2 1, and so on. It encodes binomial coefficients used in algebra and probability.
How do I read binomial coefficients from it?
The number at row n, position r equals C(n, r) - the number of ways to choose r items from n. Click any number in the triangle and the tool shows the corresponding nCr value with the formula.
What patterns can I highlight?
You can colour-code even versus odd numbers (which reveals the Sierpinski triangle fractal), multiples of any number you choose, or the Fibonacci diagonal sums. Each pattern is toggled with a button.
How many rows can I generate?
You can generate up to 30 rows. Larger triangles scroll horizontally so the numbers stay readable.
What are common uses of Pascal's triangle?
It is used for expanding binomial expressions like (a+b)^n, calculating probabilities and combinations, and studying number patterns in combinatorics courses.
Related Tools
Link to this tool
Copy this HTML to link to this tool from your website or blog.
<a href="https://toolboxkit.io/tools/pascals-triangle/" title="Pascal's Triangle Generator - Free Online Tool">Try Pascal's Triangle Generator on ToolboxKit.io</a>