Here the inner loop runs till n. Every inner iteration changes contents of A. For first inner iteration A is 1 for even or 0 for odd places. But now after first inner iteration, second outer iteration comes which starts from k+1, content of A are changed again, previous inner iteration after 1 time become meaningless. So, important thing is matching first outer iteration with first inner iteration ONLY. i think TWOLOGN is just to make confuse us