posted 13 years ago
I seem to get it a bit. Lets try,
When i = 1, print 1 only once - 1
when i = 2, print 2, twice, but enclosed between 1 at the starting and ending - 1221
when i = 3, print 3, thrice, but enclosed between 1 at the starting and ending - 13331
when i = 4, print 4, 4 times, but enclosed between 1 at the starting and ending - 144441
when i = 5, print 5, 5 times, but enclosed between 1 at the starting and ending - 1555551
What I'm not getting is the relation of input value 4 with the output. I mean if the loop starts at 1 and is <=4 only this should get printed
1
1 2 2 1
1 3 3 3 1
1 4 4 4 4 1
Are you sure the input is 4? and not 5?