Half Pyramid - 4
Given an integer N as a starting number and K as input, write a program to print a number pyramid of K rows as shown below.
Input
The first line of input is an integer N.
The second line of input is an integer K.
Explanation
In the example, the given starting number is 10, and the number of rows in the pyramid is 5.
So, the output should be
24
23 22
21 20 19
18 17 16 15
14 13 12 11 10
N=int(input())
K=int(input())
count=N-1
for row in range(K):
for col in range(row+1):
count+=1
for row in range(K):
for col in range(row+1):
print(count,end=" ")
count-=1
print()
Comments
Leave a comment