# For Loop Range with Smaller Number on Right

Simple question from an algorithm noob...

If $$i=1$$ then the inner loop will include what I believe to be an invalid range. Is this acceptable pseudocode?

For i=1 to n
For k=1 to i-1
...

• "If i=1 then the highlighted text will include what I believe to be an invalid range". Why is it an invalid range? Is empty set a valid set? Is empty range a valid range? – John L. Dec 23 '18 at 2:51

## 1 Answer

It is acceptable.

The loop says “do something for each integer $$k$$ in some range”. If there is no integer in that range, the loop just won’t do anything.

• Thank you for clearing that up for me. – Chrismo16 Dec 23 '18 at 16:34