Skip to content

Commit 2ea26be

Browse files
Create Triangle of Numbers.py
1 parent 7a22538 commit 2ea26be

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

06 Patterns2/Triangle of Numbers.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'''
2+
Problem statement
3+
Print the following pattern for the given number of rows.
4+
5+
Pattern for N = 4
6+
7+
8+
9+
The dots represent spaces.
10+
11+
12+
13+
14+
Detailed explanation ( Input/output format, Notes, Images )
15+
Constraints :
16+
0 <= N <= 50
17+
Sample Input 1:
18+
5
19+
Sample Output 1:
20+
1
21+
232
22+
34543
23+
4567654
24+
567898765
25+
Sample Input 2:
26+
4
27+
Sample Output 2:
28+
1
29+
232
30+
34543
31+
4567654
32+
'''
33+
34+
from math import *
35+
from collections import *
36+
from sys import *
37+
from os import *
38+
39+
## Read input as specified in the question.
40+
n = int(input())
41+
## Print output as specified in the question.
42+
43+
for i in range(1,n+1):
44+
for s in range(n-i):
45+
print(" ",end="")
46+
for j in range(i,2*i):
47+
print(j, end="")
48+
for k in range(2*i-2,i-1,-1):
49+
print(k ,end="")
50+
print()
51+

0 commit comments

Comments
 (0)