Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Pascal's Triangle
Bookmark
Row by Row
Combinatorial
Input
Example 1
Single row
7 rows
Custom
numRows
=
5
numRows =
5
0
1
2
3
4
each number is the sum of the two numbers directly above it
numRows =
5
0
1
2
3
4
each number is the sum of the two numbers directly above it
numRows =
5
1
0
2
3
4
i = 1
row 1
has 2 numbers
numRows =
5
1
1
1
0
1
3
4
i = 2
row 2
has 3 numbers
numRows =
5
1
1
1
1
2
0
1
3
4
i = 2
1
+
1
=
2
numRows =
5
1
1
1
1
2
1
1
0
1
2
4
i = 3
row[0]
=
1
first element is always 1
numRows =
5
1
1
1
1
2
1
1
3
0
1
2
4
i = 3
parents above:
2
and
1
numRows =
5
1
1
1
1
2
1
1
3
3
1
0
1
2
3
i = 4
row 4
has 5 numbers
numRows =
5
1
1
1
1
2
1
1
3
3
1
1
4
0
1
2
3
i = 4
1
+
3
=
4
numRows =
5
1
1
1
1
2
1
1
3
3
1
1
4
6
4
0
1
2
3
i = 4
3
+
1
=
4
numRows =
5
1
1
1
1
2
1
1
3
3
1
1
4
6
4
1
0
1
2
3
4
Σ
1
Σ
2
Σ
4
Σ
8
Σ
16
Pascal's Triangle:
5 rows
algo
master
.
io
Step:
Each number is the sum of the two numbers directly above it
0 / 31
Input
Example 1
Single row
7 rows
Custom
numRows
=
5
0 / 31
algo
master
.
io
Step:
Each number is the sum of the two numbers directly above it