PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# https://www.sololearn.com/Discuss/1035685/assignment-reverse-floyd-s-triangle
x=7 ; a=1 ; list=[['1']]
while len(list)<x:
list.insert(0,[])
for i in range(len(list[1])+1):
a+=1
list[0].insert(0,str(a))
print('\n'.join([' '.join(list[i])for i in range(len(list))]))
'''
Floyd's Triangles Challenge by Danijel Ivanović
Floyd's triangle is a right-angled triangular array of natural numbers, used in computer science education. It is named after Robert Floyd, who was an eminent computer scientist.
It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 at the top left corner.
Write a program to print the Floyd's triangle and reverse Floyd's triangle by taking the number of rows as input.
For Example:
Input: 5
Output:
Floyd's triangle:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Reverse Floyd's triangle:
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run