100 Closed Lockers Suppose you are in a hallway lined with 100 closed lockers. You begin by opening all 100 lockers. Next, you close every second locker. Then you go to every third locker and close it if it is open or open it if it is closed (call this toggling the locker). Continue toggling every nth locker on pass number n. After your hundredth pass of the hallway, in which you toggle only locker number 100, how many lockers are open?
Solution: 10 Lockers #1, 4, 9, 16, 25, 36, 49, 64, 81, and 100. Explanation: Each of these numbers are perfect squares. This problem is based on the factors of the locker number. Each locker is toggled by each factor; for example, locker #40 is toggled on pass number 1, 2, 4, 5, 8, 10, 20, and 40. That's eight toggles: open-closed-open-closed-open-closed-open-closed.
The only way a locker could be left open is if it is toggled an odd number of times. The only numbers with an odd number of factors are the perfect
squares. Thus, the perfect squares are left open.
For example, locker #25 is toggled on pass number 1, 5, and 25 (three toggles): open-closed-open.If n is the number then the number of open doors is floor(sqrt(n)) so if n=60 then sqrt(60) =6.92 floor(6.92) is 6.So the answer is 6
No comments:
Post a Comment