Skip to content

Commit bce967e

Browse files
Create 1_1_2n.py
1 parent e8b785f commit bce967e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

pattern/1_1_2n.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
n=int(input("enter no of rows: "))
2+
i=1
3+
sum=1
4+
k=0
5+
while i<=n:
6+
j=i
7+
if i%2==0:
8+
sum=sum+i-1
9+
k=sum
10+
else:
11+
sum=k+1
12+
while j>0:
13+
print(sum,' ',sep='',end="")
14+
if i%2==0:
15+
sum-=1
16+
else:
17+
sum+=1
18+
j-=1
19+
print()
20+
i+=1
21+
'''
22+
output:
23+
enter no of rows: 10
24+
1
25+
3 2
26+
4 5 6
27+
10 9 8 7
28+
11 12 13 14 15
29+
21 20 19 18 17 16
30+
22 23 24 25 26 27 28
31+
36 35 34 33 32 31 30 29
32+
37 38 39 40 41 42 43 44 45
33+
55 54 53 52 51 50 49 48 47 46
34+
'''

0 commit comments

Comments
 (0)