We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0115ee7 commit 6e948f4Copy full SHA for 6e948f4
other/Pascal_triangle.py
@@ -0,0 +1,25 @@
1
+# -*- coding: utf-8 -*-
2
+"""
3
+Created on Wed May 24 11:47:28 2017
4
+
5
+@author: Shubham Purohit
6
7
8
+n=input("Enter a value(>0):")
9
10
+if n<1: # Check if number of rows > 0
11
+ pass
12
+else:
13
+ print [1] #print first row
14
+ l=[1,1] # reference string
15
+ for i in range(1,n):
16
+ k=[1,1] # initialize output list
17
+ for j in range(1,i):
18
+ k.insert(j,(l[j-1]+l[j])) # update output list
19
+ print k # print consequent rows
20
+ l=k
21
22
23
24
25
0 commit comments