Locker Puzzle in Java
You are using i = 1 as a special case, when in fact that can be handled by your other code already:

for (int i = 1; i &lt;= 100; i++) {
    for (int j = 1; i * j &lt;= 100; j++) {
        lockers[i * j] = !lockers[i * j];
    }
}




However, to be more readable, I suggest changing the inner loop:

for (int i = 1; i &lt;= 100; i++) {
    for (int j = i; j &lt;= 100; j += i) {
        lockers[j] = !lockers[j];
    }
}


Now it reads as "Start j at i, repeat as long as j is less than or equal to 100, increase j by the value of i"