Answer to

old chestnut: opening and closing lockers:

The answer is that each locker whose number is a square number will be open.

Each locker is opened or closed by each student whose number is a factor of the locker number. So each locker is opened or closed a number of times equal to its number of factors.

Most numbers have an even number of factors. Each small factor (less than the square root of the number) can be paired with a unique factor greater than the square root.
The exception is for square numbers, because they have one factor in the middle (their square root) which is paired with itself.

For example, 12 has 6 factors: 1, 2, 3, 4, 6, 12, but 16 have 5 factors: 1, 2, 4, 8, 16.