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 3c88735 commit c05f1ceCopy full SHA for c05f1ce
patterns/number_triangle.py
@@ -0,0 +1,24 @@
1
+"""
2
+Prints a number triangle pattern.
3
+
4
+Example for n = 5:
5
+1
6
+1 2
7
+1 2 3
8
+1 2 3 4
9
+1 2 3 4 5
10
11
12
13
+def number_triangle(n: int) -> None:
14
+ """
15
+ Prints a number triangle up to n rows.
16
17
+ :param n: Number of rows
18
19
+ for i in range(1, n + 1):
20
+ print(" ".join(str(x) for x in range(1, i + 1)))
21
22
23
+if __name__ == "__main__":
24
+ number_triangle(5)
0 commit comments