Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Pascal's Triangle
Bookmark
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
2
3
4
i = 1
row 1 =
[1, 1]
numRows =
5
1
1
1
1
2
0
1
3
4
i = 2
1
+
1
=
2
numRows =
5
1
1
1
1
2
1
0
1
2
4
i = 3
row 3
has 4 numbers
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
4
i = 3
row 3 =
[1, 3, 3, 1]
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
0
1
2
3
i = 4
parents above:
3
and
1
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 / 32
Input
Example 1
Single row
7 rows
Custom
numRows
=
5
0 / 32
algo
master
.
io
Step:
Each number is the sum of the two numbers directly above it