You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pascal's triangle is a triangular array of numbers in which those at the ends of the rows are 1 and each of the others is the sum of the nearest two numbers in the row above (the apex, 1, being at the top).
4
+
5
+
"""
6
+
print("Welcome to Pascal's traingle:")
7
+
8
+
9
+
n=int(input("Enter number of rows for the pascal's traingle: "))
10
+
a=[]
11
+
foriinrange(n):
12
+
a.append([])
13
+
a[i].append(1)
14
+
forjinrange(1,i):
15
+
a[i].append(a[i-1][j-1]+a[i-1][j])
16
+
if(n!=0):
17
+
a[i].append(1)
18
+
19
+
20
+
# printing pascal's triangle
21
+
print( " Your Pascal's traiange for the number {}".format(n))
0 commit comments