Answer to Question #224843 in Python for hari

Question #224843
NUMBERED TRIANGLE
you are given an integer N. print N rows starting from 1 in the triangle order as shown in the explanation.
INPUT
the input contains an integer N .
OUTPUT
the output shoudl have N lines .
Each of the N lines should have space -seperated integers as per the traingle order.
EXPLANATION
given N = 5
the triangle order for the given N is
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
1
Expert's answer
2021-08-10T05:59:46-0400
n = int(input())
for i in range(n):
    print(*[i + 1 + int((n - (j + 1) / 2) * j) for j in range(i + 1)])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS