Suppose you're in a hallway lined with 100 closed lockers. You begin by opening every locker. Then you close every second locker. Then you go to every third locker and open it (if it's closed) or close it (if it's open). Let's call this action toggling a locker. Continue toggling every nth locker on pass number n. After 100 passes, where you toggle only locker #100, how many lockers are open?
Answers
Answer: The number of toggles of a door determines its final status. If a door is toggled for odd times, it will end up with open. If even time, the door will be closed at the end.
Also noticed that, after nth pass, door number <= n will not be touched anymore.
For door #1, it will be toggled once therefore it will end up open.
For door #2, it will be toggled twice (in pass 1 and 2) and is end up closed.
For door #3, it is toggled twice (pass 1, 3) and ends up closed.
For door #4, it is toggled 3 times (pass 1, 2, 4) and ends up open.
....
For door #100, it is toggled 9 times (pass 1, 2, 4, 5, 10, 20, 25, 50 and 100) and ends up open.
Therefore, this problem can be reduced to finding the numbers that have odd number of factors between 1 and itself, and 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100 has this property. This is because all other numbers have even number of factors that can multiply to itself while the above 10 have one more, which is the square root of itself.
i think the answer should be 10
Answer:
Explanation:
There are 100 lockers, and as stated we open all 100 lockers, and then we close every second locker, then 50 lockers are closed, and then we close or open every third locker which leaves us with 25 lockers which are either opened or closed.
If the same is continued till we reach the 100th locker then depending on the number to lockers closed which are to be opened would be remaining.