2.1 Mirror Number Pattern Hint
2.1 Mirror Number Pattern Hint
Problem Description: You are given with an input number N, then you have to print the given
pattern corresponding to that number N.
For example if N=4
Pattern output : 1
12
123
1234
How to approach?
1. Take N as input from the user.
2. Figure out the number of rows, (which is N here) and run a loop for that.
3. Now, figure out how many columns are there in ith row and run a loop for that within
this. Here, first you need to run a loop to print the spaces too.
4. Now, figure out “What to print?” in a particular (row, column). It can depend on the
column number, row number or N.
● i=2(<=4)
➔ 4-2=2 spaces are getting printed first.
➔ j=1 (<=2), so print 1
➔ j=2 (<=2) , so print 2
➔ j=3(>2), move out of the inner loop with a new line
● i=3(<=4)
➔ 4-3=1 space is getting printed first.
➔ j=1(<=3), so print 1
➔ j=2(<=3), so print 2
➔ j=3(<=3), so print 3
➔ j=4(>3), move out of the inner loop with a new line
● i=4(<=4)
➔ 4-4=0 no space is getting printed.
➔ j=1(<=4), so print 1
➔ j=2(<=4), so print 2
➔ j=3(<=4), so print 3
➔ j=4(<=4), so print 4
➔ j=5(>4), move out of the inner loop with a new line
So , final output:
1
12
123
1234