Right,
I thought of that initially, but then I thought the range perhaps includes both the numbers (0 and 36). Jennifer, if 36 is not included as one of the numbers here, pls. make iMax as 35 or change the condition as Cindy says.
As for documentation, I am too lazy to do that. Perhaps, you can do that part of your assignment yourself.
OK, I'll try to explain what the code does -
Consider your code contaning 3 numbers (not digits), XYZ. Each can range from 0 to 36 (or 35). Each loop is generating these numbers.
Outermost (i loop) => X
Middle (j loop) => Y
Innermost (k loop) => Z
For each iteration of the outer loop the immediate inner loop executes 37 (or 36) times. A basic permutaion/combination question. Think of it in this way, how many 2 digit numbers you can have from digits 0 to 9 (both inclusive). It gives you -
XY as a combination, where X & Y both can take values in the range 0 to 9. You can have hundred such numbers (0 to 99).
I hope this make it easy for you to understand the code. In your case, the total combinatioons will be (37 * 37 * 37 = 50653 OR 36 * 36 * 36 = 46656).
HTH,
- Manish
p.s. - Cindy, thanks for pointing this. I wanted to include this assumption in my post but just forgot.