Question #223541

Half Pyramid - 3

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

input-1

10

5

output-1

10

11 12

13 14 15

16 17 18 19

20 21 22 23 24


Sample Input 2

1

3

Sample Output 2

1

2 3

4 5 6




Expert's answer

n = int(input())
k = int(input())

for i in range(k + 1):
    for j in range(i):
        if i == j + 1:
            print(n)
        else:
            print(n, end=' ')
        n += 1
LATEST TUTORIALS
APPROVED BY CLIENTS