### 100 Doors in a Row

Problem: you have 100 doors in a row that are all initially closed. you make 100 passes by the doors starting with the first door every time. the first time through you visit every door and toggle the door (if the door is closed, you open it, if its open, you close it). the second time you only visit every 2nd door (door #2, #4, #6). the third time, every 3rd door (door #3, #6, #9), etc, until you only visit the 100th door.

question: what state are the doors in after the last pass? which are open which are closed?

question: what state are the doors in after the last pass? which are open which are closed?

only perfect square will have their state closed and others will have their state opened.

ReplyDeletecheck why??

Only the perfect squares will remain open as only they have odd number of divisors.

ReplyDeleteAny other number will have even number of divisors.

Let me give an example -

say the number is 12, its divisors are 1,2,3,4,6,12. It will have equal divisors above and below its square root value. Since the square root value is not an integer the number of divisors remain even. However in the case of a perfect square, the square root is a perfectly valid integer making the number of divisors odd.

yeah right

ReplyDelete