An old chestnut goes like this:

In a school, there is a row of N lockers numbered consecutively 1 to N, initially all closed.

A bunch of students walk by. The first student opens every locker. The second student closes every even-numbered locker. The third student opens or closes (whichever is possible) each locker with a number that is a multiple of three. This continues, with each student opening and closing lockers that are numbered with multiples of his number.

Finally, after the Nth student has walked by the lockers, which lockers are open?


Log in or register to write something here or to contact authors.