The Locker Problem Extended

Every day, 100 students enter a school that has 100 lockers. All the lockers are closed when they arrive.

Student 1 opens every locker.

Student 2 closes every second locker.

Student 3 changes the state of every third locker i.e. he opens it if it is closed and closes it if its open.

Student 4 changes the state of every fourth locker and so on... so that student n n changes the state of every n th n^\text{th} locker.

One day, however a few of the students are absent. Regardless, those present complete the procedure and simply skip the students who are absent. For e.g. if student 3 is absent, then nobody changes the state of every third locker.

At the end of the process, it is found that only locker number 1 is open and all the other 99 lockers are closed.

How many students were absent that day ?


The answer is 39.

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.

4 solutions

Satyen Nabar
Jan 9, 2015

The original locker problem shows us that the lockers with numbers that have an odd number of divisors stay open. Since the lockers are closed at the start all the lockers that are handled by odd number of students will remain open.

The perfect squares are the only numbers that can have an odd number of divisors. So the students with square numbers have to be absent.

Since they are absent, all the multiples of the square numbers will also have to be absent.

Let us see why. The square number 4 has 3 divisors 1,2 ,4 so 4 must be absent. Since 4 is absent consider what happens to 8. The divisors of 8 are 1, 2, 4, 8. Since 4 is absent, 8 now has an odd number of divisors so 8 also has to be absent. Same for 12 and all multiples of 4. For eg 16 has divisors 1, 2, 4, 8,16. we know 4 and 8 are both absent so 16 now has 3 divisors and therefore must also be absent.

These numbers are called Squareful numbers. In other words all the numbers that have repeated factors will all be absent.

Multiples of 4 --- 25 numbers

Multiples of 9 --- 9 numbers not counting 36 and 72

Multiples of 25 ---3 numbers not counting 100

Multiples of 49 -- 2 numbers

Total 39 students were absent.

This is a nice extension of the locker problem.

Your solution does not work as yet. You are missing a step inbetween. For example, even though we know that locker 16 is closed, that just means that either 1, 3 or 5 students of number 1, 2, 4, 8, 16 are not around. We currently are unable to immediately conclude that 16 is not around.

Calvin Lin Staff - 6 years, 5 months ago

Log in to reply

39 people absent??? Wow, must be a chemistry test today. :P

Trevor Arashiro - 5 years, 10 months ago

Tx Calvin. Yes got your point. Also do check out the part 2 of the locker problem extension that i just posted.

Satyen Nabar - 6 years, 5 months ago

Yes I thought that too. I felt maybe it should be minimum I think if we can change the question to Minimum how many students were absent, then it is conclusive.

Soumya Chakraborty - 6 years, 5 months ago

Have made it clearer now thanks, Calvin

Satyen Nabar - 6 years, 4 months ago

This is really an excellent problem,I really liked problem.It is amazing.

Kalpok Guha - 6 years, 5 months ago

Log in to reply

Tx. Also try Locker Problem Extension Part 2 that I have just posted...

Satyen Nabar - 6 years, 5 months ago

Log in to reply

Sir please see the note Locker Problem Theory I have posted

Kalpok Guha - 6 years, 4 months ago

Log in to reply

@Kalpok Guha Will definitely do so. Tx Kalpok

Satyen Nabar - 6 years, 4 months ago

great problem

prajwal kavad - 6 years, 4 months ago

If 99 members were absent on first day... From student 1 to student 99 then also it is 1 locker open and other are closed 😊

Sudhamsh Suraj - 4 years, 4 months ago

(This is to show how only square no.. undergo changes)

Basically you have a system of 100 states, each of which is binary (either open or closed). Each binary 'cell' (b1, b2, b3,...,b100) can either be 0 (closed) or 1 (open). All start out 0, and each operation changes its value.

Now, since each cell is acted on whenever the student number (1 to 100) is a factor of it, the cell changes state a number of times equal to the number of its factors, right? And if it changes state an even number of times, it ends up closed, and if it changes state an odd number of times, it ends up open. So this question boils down to: How many numbers from 1 to 100 have an even number of factors, and how many have an odd number of factors?

The factors of a number are those numbers that the original number is evenly divisible by. In all cases, the result of such a division is also a factor (I will call this a 'cofactor'). This means that unless one of the factors is the square root of the number, the number will have an even number of factors. If one of the factors is the square root of the number, then the cofactor is itself. For all other factors, there will be a cofactor, and thus an even number of them. Since an even number plus 1 is an odd number, any perfect square, and only a perfect square, will have an odd number of factors.

So, all that mess means the following:

Every locker whose number is a perfect square will be open. This means that lockers 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100 will be open, for a total of 10. There is no correlation between evenness

Kundan Patil - 6 years, 5 months ago

Log in to reply

I made the same mistake in my first attempt, but please note that once you remove for example student number 4, the lockers number 8, 12 and so on, will now remain open, then those students has to be absent as well. The solution is explained really well by Satyen Nabar at the beginning of the solutiones

Ramiro del Alamo - 6 years, 2 months ago

Why r u not counting 36 n 72 among the ones absent

Ahuv Meinser - 5 years, 5 months ago

Log in to reply

Cos they are multiples of 4 and are already counted as absent!

Satyen Nabar - 5 years, 5 months ago
Ariel Gershon
Jan 10, 2015

Let s ( n ) = 1 s(n) = 1 if student n n is present, and 0 0 is student n n is absent.

It's not too difficult to see that Locker n n is closed if and only if an even number of students change its state. Also, the state of Locker n n is changed by Student k k if and only if k n k | n . Hence, for each locker n 1 n \neq 1 , we must have s ( k ) = 1 s(k) = 1 for an even number of numbers k k which are factors of n n .

L e m m a : \underline{Lemma:} s ( n ) = 1 s(n) = 1 if and only if the integer n n is square-free. (square-free means it is not divisible by any perfect square 4 \ge 4 ).

P r o o f : \underline{Proof:}

I will use strong induction to prove this fact.

Base Case: When n = 1 n = 1 , the only factor of 1 1 is 1 1 . So, since Locker 1 1 is opened, Student 1 1 must be there to open it. Hence s ( 1 ) = 1 s(1) = 1 .

Strong Induction Hypothesis: Suppose that for all 1 i < k 1 \le i < k for some fixed k k , we have s ( i ) = 1 s(i) = 1 if and only if i i is square-free.

Case (1) : Suppose k k is square-free

Since k k is square-free and k > 1 k > 1 , it must have an even number of divisors, and logically all of its divisors are also square-free. By the induction hypothesis, all of its proper divisors are not absent, and there is an odd number of them. Hence, in order for Locker k k to be closed, k k must also not be absent, so s ( k ) = 1 s(k) = 1 .

Case (2): Suppose k k is not square-free.

Let f ( n ) f(n) represent the product of all primes p p which divide n n . (for example, f ( 72 ) = 2 3 = 6 f(72) = 2 * 3 = 6 ). We can quickly derive three important properties: (a) All square-free factors of n n are also factors of f ( n ) f(n) ; (b) All factors of f ( n ) f(n) are square-free, including f ( n ) f(n) itself; and (c) if n n is not square-free, then 1 < f ( n ) < n 1 < f(n) < n .

By the induction hypothesis, proper divisors of k k are not absent if and only if they are square-free, and by (a) and (b), these numbers are exactly the factors of f ( k ) f(k) . Now since f ( k ) f(k) is square-free and f ( k ) > 1 f(k) > 1 , then f ( k ) f(k) has an even number of divisors. Hence, k k has an even number of proper divisors that are not absent. Therefore, for Locker k k to be closed, Student k k must be absent. Hence s ( k ) = 0 s(k) = 0 .

Therefore s ( k ) = 1 s(k) = 1 if and only if k k is square-free. Hence the induction is complete.

QED

Mark Hennings
Nov 21, 2015

If n 1 n \ge 1 , suppose that the prime factorization of n n is n = p 1 a 1 p 2 a 2 p k a k . n \; = \; p_1^{a_1}p_2^{a_2} \cdots p_k^{a_k} \;. The factors of n n which themselves have no repeated prime factors are of the form i S p i \prod_{i\in S} p_i for any subset S S of { 1 , 2 , , k } \{1,2,\ldots,k\} . Thus n n has 2 k 2^k (an even number of) such factors.

Thus, if the students who are present are precisely those whose index has no repeated prime factor, then every door with index greater than 1 1 will have its state changed an even number of times, and end up closed. On the other hand, the first door will only have its state changed once, so will end up open.

The students who are absent are those whose index has a repeated prime factor. There are 39 39 such numbers between 1 1 and 100 100 .

David Krüger
Mar 13, 2016

Once again, not a true number theory answer, but Octave/Matlab brute forced answer:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
% 0 = open
% 1 = closed

% i is locker number (a(i) is locker state)
% j is "current student" and multiples

% Student 1 is skipped for convinience (a = zeros, i =/= 1)

a = zeros(100,1);
b = 0;

for i = 2:100

    if a(i) == 0

        for j = 1:100

            if rem(j,i) == 0 % every multiple of student number

                if a(j) == 0 % close if open
                    a(j) = 1;
                elseif a(j) == 1% open if closed
                    a(j) = 0;
                else
                    disp 'error: a(j) =/= 0 or 1'
                end

            end
        end

    elseif a(i) == 1
        b = b + 1; % Student was absent, add one to count.

    else
        disp 'error: a(i) =/= 0 or 1'

    end
end

b

OUTPUT: b = 39

I chose not to include variable 'a' here, but I did check it to make sure it was '0' followed by 99 '1's.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...