students enter a school that has lockers. All the lockers are closed when they arrive.
Every day,Student opens every locker.
Student closes every second locker.
Student changes the state of every third locker i.e. he opens it if it is closed and closes it if its open.
Student changes the state of every fourth locker and so on... so that student changes the state of every locker.
One day, on account of a blizzard, several students are absent. Regardless, those present complete the procedure and simply skip the students who are absent. For e.g. if student is absent, then nobody changes the state of every third locker.
At the end of the process, it is found that only locker number is open and all the other lockers are closed...
How many students were absent that day ?
More interestingly, given a locker number n, find a general rule that keeps only locker n open and all other lockers closed.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Instead of finding students that were absent, lets find the number of students that were present that day.
We know that if student 1 was present he would open all lockers including 1. But we want only locker 4 to be open, so 1 must be absent. Same goes for student 2 and 3.
Student 4 has to be present for locker to open. However this now opens lockers 8, 12, 16, 20...
Student 8 must be present to close locker 8 but now that closes lockers 16, 24, 32, 40.... However lockers 12, 20, 28, 36... are still open.
Student 12 must be present but this reopens lockers 24, 48, 72 and 96. Student 20 must be present as also student 24. Sending student 20 opens up locker 40 again.
Working on this thoroughly we find that the list of 16 students that were present that day were 4, 8, 12, 20, 24, 28, 40, 44, 52, 56, 60, 68, 76, 84, 88, 92. Thus 84 absent...
Now for the general rule.
Squarefree numbers are the numbers that do not have repeated factors or are not multiples of squares other than 1.
The list of squarefree numbers is { 1, 2, 3, 5, 6, 7, 10, 11, 13, 14,.....}
Now if we want locker 4 to be open we simply multiply this set by 4 and lo and behold we have the students who were present. This works for any locker number n that you want to keep open .
The number of students present will be n {Set of squarefree numbers}