A bored student walks down a hall that contains a row of closed lockers, numbered 1 to 1024. He opens the locker numbered 1, and then alternates between skipping and opening each closed locker thereafter. When he reaches the end of the hall, the student turns around and starts back. He opens the first closed locker he encounters, and then alternates between skipping and opening each closed locker thereafter. The student continues wandering back and forth in this manner until every locker is open. What is the number of the last locker he opens?
Solution
To solve this problem, we need to carefully track the student's movements and the lockers he opens. Let's break down the process step-by-step.
1. First Pass (Forward):
- The student starts at locker 1 and opens it.
- He then skips one locker and opens the next one, continuing this pattern until he reaches the end of the hall.
- This means he opens all odd-numbered lockers: 1, 3, 5, ..., 1023.
- Total lockers opened in this pass: .
2. Second Pass (Backward):
- The student turns around and starts back from locker 1024.
- He opens the first closed locker he encounters, which is locker 1022 (since all odd-numbered lockers are open).
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every fourth locker: 1022, 1018, 1014, ..., 4.
- Total lockers opened in this pass: .
3. Third Pass (Forward):
- The student turns around again and starts from locker 1.
- He opens the first closed locker he encounters, which is locker 2.
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every eighth locker: 2, 10, 18, ..., 1018.
- Total lockers opened in this pass: .
4. Fourth Pass (Backward):
- The student turns around again and starts from locker 1024.
- He opens the first closed locker he encounters, which is locker 1022.
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every sixteenth locker: 1022, 1006, 990, ..., 14.
- Total lockers opened in this pass: .
5. Fifth Pass (Forward):
- The student turns around again and starts from locker 1.
- He opens the first closed locker he encounters, which is locker 6.
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every thirty-second locker: 6, 38, 70, ..., 998.
- Total lockers opened in this pass: .
6. Sixth Pass (Backward):
- The student turns around again and starts from locker 1024.
- He opens the first closed locker he encounters, which is locker 1014.
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every sixty-fourth locker: 1014, 950, 886, ..., 54.
- Total lockers opened in this pass: .
7. Seventh Pass (Forward):
- The student turns around again and starts from locker 1.
- He opens the first closed locker he encounters, which is locker 22.
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every 128th locker: 22, 150, 278, ..., 918.
- Total lockers opened in this pass: .
8. Eighth Pass (Backward):
- The student turns around again and starts from locker 1024.
- He opens the first closed locker he encounters, which is locker 982.
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every 256th locker: 982, 726, 470, ..., 214.
- Total lockers opened in this pass: .
9. Ninth Pass (Forward):
- The student turns around again and starts from locker 1.
- He opens the first closed locker he encounters, which is locker 86.
- He then skips one closed locker and opens the next one, continuing this pattern.
- This means he opens every 512th locker: 86, 598.
- Total lockers opened in this pass: .
10. Tenth Pass (Backward):
- The student turns around again and starts from locker 1024.
- He opens the first closed locker he encounters, which is locker 854.
- This is the only locker he opens in this pass.
- Total lockers opened in this pass: .
Thus, the last locker he opens is locker number .