• + 2 comments
    1. I loop from 1 to the maximum number (n).
    2. And then I print a number of # amounting to the current loop index on each line followed with a newline break.
    3. But since this will lead to the output being aligned on the left, I also print (n-i) spaces on each line where n is the maximum number and i is the current loop index before executing (2). So for instance when i is 1, I print 5 spaces before I print 1 # to fill up the six spaces (total number of spaces on each line). When i is 2, I print 4 spaces before I print 2 # to make sure all the six spaces on the line are filled. This also ensures that the # is aligned to the right.

    NB. The range is (1, n+1). I didn't start from 0 because that will cause an empty space at the beginning of the output and I also ended at n+1 because the loop ends and n-1 so I add 1 to get to the correct n.

    Do you get it now?