Friday, October 10, 2014

Locker doors there are n lockers in a hallway, numbered sequentially from 1 to n. Initially, all the...

Locker doors there are n lockers in a hallway, numbered sequentially from 1 to n. Initially, all the locker doors are closed. You make n passes by the lockers, each time starting with locker #1. On the it pass, i = 1, 2, . . . , n, you toggle the door of every it locker: if the door is closed, you open it; if it is open, you close it. After the last pass, which locker doors are open and which are closed? How many of them are open?

No comments:

Post a Comment