Your 'i' will only have a value of 0, the first time the outer loop is run, in the example on the page, it is initiated to 0 on each run.
Code:
/* n is a straight up integer */
j = 0;
while(n) {
i = 0;
do {
j = ( j + state[i] + state2[i] );
x = state[i];
state[i] = state[j];
state[j] = x;
i++;
} while (i);
n--;
}