So, yesterday I posed a little conundrum, inviting readers to comment to solve it. Either my audience base is (a) too small to generate a single comment, (b) too low-brow for such fripperies or (c) scuppered, such is the lack of feedback shown. Anyway, here's the solution.
With 100 lockers and students, the answer is 10. If there were 10,000 lockers and students, then 100 lockers would be open at the end, although trying to coordinate so many students and making sure there were no renegades flouting their responsibilities may affect the outcome.
It took me a while (and a bit of prompting) to figure it out, but I finally got there. You see, each locker has its state changed by every one of its divisors. So locker twelve's state is changed by students one, two, three, four, six and twelve. For the majority of numbers, their divisors can be paired off: in this case 1 x 12, 2 x 6, 3 x 4. The only numbers for which this isn't the case are perfect squares. Take 36, for example. 1 x 36, 2 x 18, 3 x 12, 4 x 9, 6 x 6. And here's the beauty. Because the six multiplies by itself, it only counts once as a divisor - it has no partner, bar itself. So, 36 has nine divisors (odd) as opposed to twelve which has six (even). The broader lemma is that perfect squares have an odd number of divisors; all other numbers have an even number. Poetry.
So going back to the 100 lockers, those that are perfect squares (1, 4, 9, 16, 25, 36, 49, 64, 81, 100) will be opened/closed an odd number of times (and thus end up open), while all others will be opened/closed an even number of times (ending up closed).
The square root of a number indicates how many perfect squares there are up to and including that number. So if there are X students and X lockers, then at the end of the day, there will be rounddown(X^0.5) lockers open - i.e. the square root of the total, rounded down to the nearest integer. If there are 10,000 lockers, then there'll be 100 open at the end. 10,010 will yield the same result.
I like the puzzle, because at first, it seems pretty complicated. But applying some maths to it shows that the answer's pretty simple.
