Write a program to print a print pyramid pattern shown below

Description:

  • Read a number from user. Let’s say if number is 5, you need to print numbers in pyramid pattern as shown below:

If n = 5, then,
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
Note:- Please consider ‘_’ as space. You need to leave space between 2 numbers


Pre-requisites:

  • Loops

Inputs:

  • Read an Integer ‘n’ from the user

Sample Output:


Test Case 1:


Enter the number: 4
4
3 4
2 3 4
1 2 3 4
2 3 4
3 4
4


Test Case 2:


Enter the number: 5
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5