Skip to content

Commit aadbbbd

Browse files
Create 1_2_1n.py
1 parent 413c1dc commit aadbbbd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pattern/1_2_1n.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
n=int(input('enter a number'))
2+
for i in range(1,n+1):
3+
for j in range(0,n+1-i):
4+
if i<=(n//2+n%2):
5+
print(i%(n//2+n%2+1),end='')
6+
else:
7+
if n%2!=0:
8+
print(n//2+n%2-i%(n//2+n%2),end='')
9+
else:
10+
print(n//2-i%(n//2+1),end='')
11+
print()
12+
'''
13+
output:
14+
enter a number8
15+
11111111
16+
2222222
17+
333333
18+
44444
19+
4444
20+
333
21+
22
22+
1
23+
'''
24+
'''
25+
output:
26+
111111111
27+
22222222
28+
3333333
29+
444444
30+
55555
31+
4444
32+
333
33+
22
34+
1
35+
'''

0 commit comments

Comments
 (0)