- #1

- 4

- 0

## Main Question or Discussion Point

Consider the following segment where

counter := 0

for i := 1 to n do

for j :=1 1 to i do

for k :=1 to j do

counter := counter + 1

I am so lost as to what this program is even doing. Can anyone help explain what is does? I just need to know what it does upon first execution, second execution, etc.. and I may be able to solve it from there.

*i,j,k,n*and*counter*are integer variables and the value of*n*(a positive integer) is set prior to this segment.counter := 0

for i := 1 to n do

for j :=1 1 to i do

for k :=1 to j do

counter := counter + 1

I am so lost as to what this program is even doing. Can anyone help explain what is does? I just need to know what it does upon first execution, second execution, etc.. and I may be able to solve it from there.