Answer to Question #238166 in Python for C N Manjula

Question #238166
You are given an integer N. Print N rows starting from 1 in the triangle order as shown in the explanation.
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-09-16T15:36:44-0400
N=int(input())


for i in range(N):
    v=i+1
    d=N-1
    for j in range(i+1):
        print(format(v,"<4"),end=" ")
        v=v+d
        d=d-1
        
    print()

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