There are 100 mailboxes numbered 1 to 100 that are all initially closed. In the first step, visiting every mailbox (i.e. mailboxes 1, 2, 3, …, 100), he flips them all. Then in the second step, visiting every second mailbox (i.e. mailboxes 2, 4, 6, …, 100), he flips them. Then in the third step, visiting every third mailbox (i.e. mailboxes 3, 6, 9, …, 99), he flips them. In this manner he goes in steps of 4, 5, …, 10,…,50, and finally 100, wherein he directly goes to the 100th mailbox and flips it. At the end of this process, which mailboxes are open? Hint: Set up an array of Booleans all initialized to false representing closed mailboxes. Then, in steps of 1, 2, 3,



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *