In every step, the program increases
i by one. The program terminates when
n . The “outer loop” is run
There is also an “inner loop” about
j . But all it does is increase
j until it reaches
i (at most, sometimes it does less).
j is never decreased. So that part is also run at most
n times in total (not
n times for each iteration of the “outer loop”).