Some pseudo code:
Code:
valueA = 0
limit = 5
while (valueA < limit)
valueB = 0
while (valueB <= valueA)
print valueB
valueB = valueB +1
valueA = valueA +1
print <cr>
This takes care of the first part ie:
0
01
012
0123
01234
It's almost the same idear in the remaining part.
I'll be back tomorrow morning (atleast in my timezone) to post my solution
Edit:
I'm back, if you dont want to see the solution, then don't scroll past this line