![]() |
VOOZH | about |
A hollow half-pyramid pattern using numbers is a type of pattern that seems like a pyramid shape mostly it is considered a star pattern but here we will be creating using numbers.
Program to print the following pattern of a half pyramid for N.
Example:
Input: N = 5
1
1 2
1 3
1 4
1 2 3 4 5
Below is the implementation of the above approach:
1 1 2 1 3 1 4 1 2 3 4 5
Reason: we are looping through the rows and columns of the pattern.
Reason: This algorithm does not require any additional space.
Printing an Inverted pyramid of a pattern is mostly the same as printing the pyramid normally just changes in a few conditions and we are all done. Let us check the code.
Example:
input: N = 6
1 2 3 4 5 6
2 6
3 6
4 6
5 6
6
1 2 3 4 5 6 2 6 3 6 4 6 5 6 6
Reason: we are looping through the rows and columns of the pattern.
Reason: This algorithm does not require any additional space.