A certain hallway contains a row of lockers numbered from 1 to 30.

  • Thread starter Thread starter snipez90
  • Start date Start date
  • Tags Tags
    Row
AI Thread Summary
In a hallway with 30 lockers, all initially closed, 30 students sequentially toggle the state of the lockers based on their position. The first student opens all lockers, while each subsequent student toggles the lockers that are multiples of their student number. The key insight is that a locker will end up open if it is toggled an odd number of times. This occurs for lockers that are perfect squares, as they have an odd number of divisors. The perfect squares among the numbers 1 to 30 are 1, 4, 9, 16, 25, resulting in 6 lockers remaining open. Consequently, the total number of lockers that remain closed after all students have finished is 30 - 6 = 24.
snipez90
Messages
1,095
Reaction score
5
A certain hallway contains a row of lockers numbered from 1 to 30. All the lockers are initially closed. 30 students are lined up in the hallway. The first student walks down the row and opens up all the lockers. The second student closes all the lockers numbered 2, 4, 6, ..., 30. The third student performs an operation on the lockers numbered 3, 6, 9, ..., 30; if a locker was open, he closes it and if a locker was closed, he opens it. For the n-th student, he operates on the lockers numbered by multiples of n; if a locker was open, he closes it and if a locker was closed, he opens it. How many lockers remain closed after all 30 students finish their walks?
 
Physics news on Phys.org


Answer:
24
Proof: (sorry, I don't know how to hide the proof)

Code:
oooooooooooooooooooooooooooooo
 c c c c c c c c c c c c c c c
  c  o  c  o  c  o  c  o  c  o
   o   o   c   o   o   c   o
    c    o    o    c    c    c
     c     o     c     o     o
      c      o      o      c
       c       c       c
        o        o        o
         c         o         c
          c          o
           c           o
            c            o
             c             o
              c              o
               o
                c
                 c
                  c
                   c
                    c
                     c
                      c
                       o
                        o
                         c
                          c
                           c
                            c
                             c
 


25.

Door number n will be closed if n has an even number of divisors, and open if n has an odd number of divisors. The divisor function phi0(n) is odd iff n is a perfect square. Since there are five perfect squares between 1 and 30, there will be five open doors when all students finish their tasks. The other 25 doors will be closed.
 
Last edited:


When I first saw this problem it was asked with 1000 lockers, it still really easy to figure out with that number, but initially it makes it sound harder.
 
Similar to the 2024 thread, here I start the 2025 thread. As always it is getting increasingly difficult to predict, so I will make a list based on other article predictions. You can also leave your prediction here. Here are the predictions of 2024 that did not make it: Peter Shor, David Deutsch and all the rest of the quantum computing community (various sources) Pablo Jarrillo Herrero, Allan McDonald and Rafi Bistritzer for magic angle in twisted graphene (various sources) Christoph...
Thread 'My experience as a hostage'
I believe it was the summer of 2001 that I made a trip to Peru for my work. I was a private contractor doing automation engineering and programming for various companies, including Frito Lay. Frito had purchased a snack food plant near Lima, Peru, and sent me down to oversee the upgrades to the systems and the startup. Peru was still suffering the ills of a recent civil war and I knew it was dicey, but the money was too good to pass up. It was a long trip to Lima; about 14 hours of airtime...

Similar threads

Replies
16
Views
13K
Replies
1
Views
3K
Replies
10
Views
5K
Replies
3
Views
2K
Replies
7
Views
17K
Back
Top