At a hotel there are n rooms all located along a long corridor numbered consecutively from 1 to n. After a family gathering n people likewise numbered from 1 to n arrived and proceed as follow: guest 1 opened all of the doors. Guest 2 closed every second door beginning with door 2 and guest 3 changed the position of every third door starting with the third door. This process continued until each person had walked the length of the corridor. Which doors were open and where are closed at the end of the process.
Its a puzzle of door.
All door numbers which are perfect squares will remain open at the end and rest all will be closed.
Detailed explanation.
You can figure out that for any given door, say door #38, you will visit it for every divisor it has. so it has 1 & 38, 2 & 19. so on pass 1 i will open the door, pass 2 i will close it, pass 19 open, pass 38 close. For every pair of divisors the door will just end up back in its initial state. so you might think that every door will end up closed? well what about door #9. 9 has the divisors 1 & 9, 3 & 3. but 3 is repeated because 9 is a perfect square, so you will only visit door #9, on pass 1, 3, and 9… leaving it open at the end. only perfect square doors will be open at the end.
Get Answers For Free
Most questions answered within 1 hours.