Saturday, September 1, 2007

100 Lockers Puzzle

100 Lockers Puzzle

A teacher while evaluating the answer sheets of some 100 4th grade students found some similarities in most of the answers. Startled at this he asked the students about it. But none of them answered. At this he gave a punishment to all of them and to find out the final result of the exercise given as the punishment.
The exercise is as follows

The school has 100 lockers. One by one each student has to go the lockers and open them in the following pattern:
Student 1 opens all the lockers
Student 2 goes and closes every second locker
Student 3 goes and "changes the state" of every third locker i.e. if its open , close etc and vice versa.
Student 4 changes the state of every 4th locker.
.
.
.
.Student n changes the state of every nth locker
This goes on for all 100 students.

They have to tell which all lockers are open at the after 100th student is done with his task.
Now he gave one liberty to the students , if they can think of the correct solution, they need not run to the lockers and perform the task physically. But if they do it wrong they have to do that everyday.

Please help the students by telling the solution and find out which all lockers are open at the after 100th student is done with his task.
---

4 comments:

  1. The solution goes like this:
    All the lockers whose id numbers have even no. of factors (including 1 and themselves) will be closed, and the id's with odd number of factors will be open.

    Now it can be seen that only Perfect Squares have odd no. of factors.
    Hence lockers 1, 4,9,16,25,36,49,64,81,100 will be open

    ReplyDelete
  2. The open locker numbers ll be 3,4,5,7.
    As all other nos either includes themselves or they are being included in the series created by their factors ...

    ReplyDelete
  3. The open locker numbers ll be 3,4,5,7.
    As all other nos either includes themselves or they are being included in the series created by their factors ...

    ReplyDelete
  4. Nice solution here:

    http://www.programmerinterview.com/index.php/puzzles/lockers-puzzle/

    ReplyDelete

Subscribe via email

Enter your email address:

Delivered by FeedBurner