We have already a programmed a similar design pattern consisting of only stars (Diamond; Pattern 5).
We will follow a set procedure to reach the required output format in the problem.
First, we will revisit the programming implementation of diamond pattern. It is assumed that you know how it is implemented. Moving forward from there
Then, we will formulate code for printing output:
From here, we will proceed on to having variable values in the design content, rather than a constant value like 1. Output will be as follows:
Now that we have got increasing numbers in succeeding rows, we will try implementing symmetry about the middle row, by first increasing value variable(let "val") and then decreasing it. Output print would be:
We notice that in the final output that we need, we get a sequence like 2 3 2 in the second row. So, we add an increasing sequence to succeeding rows by introducing another variable(let "cval") that initializes itself from the current value of value variable ("val";which is decided by outer loop). Output:
But we realize that the pattern symmetry is also aligned along the vertical middle.
So, we increase the other (cval) value variable until it reaches the middle column and then decrease it. Then we can reach the desired output:
Now, Let us begin with the programming implementation for each of the following output formats.
Constant Value (placing 1 instead of stars)
Increasing sequence starting from row numbers
Adding increasing sequence to previous pattern
Creating symmetry about center
Creating symmetry about center column
For input value n = 5