-1
I’m developing an algorithm to form and display a Triângulo de Floyd
with n
lines.
The code is just below:
n = int(input(f'Digite o número de linhas: '))
m = 1
for c in range(1, n + 1):
for i in range(1, c + 1):
print(m, end=' ')
m += 1
print()
It occurs that when n <= 3 the columns are displayed perfectly symmetrical, just like the result...
1
2 3
4 5 6
However, if n > 3 the columns begin to present themselves desalinhadas
. Example, n = 5
...
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
How could you organize the columns of the Floyd Triangle so that they are symmetrical (properly ordered) for all n <= 40?