The Prison Guard

There is a prison guard named Sam. He is guarding a prison with exactly 100 inmates. Each inmate is locked in her/his own cell. However, Sam knows that all the prisoners are here for political reasons, and none of them committed any crime except for dissent. So he decides to free them.

First, he walks down the hallway and opens every cell door. Then he realizes that this is too obvious, so he goes back and changes every other cell door, closing it if it is open and opening it if it is closed. Then he thinks that this is too obvious as well, so he goes back and changes every 3rd door. Then since he is getting into a rhythm, he thinks he might as well keep going in this pattern; changing every 4th door, 5th door, then 6th, then 7th, all the way the 100th door.

So here's the question: what are the doors that will be open by the time Sam is done?

Please list the door numbers in a string without spaces. Example: 2, 3, and 16 would be 2316.


The answer is 149162536496481100.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Estella Z.
Oct 29, 2017

This problem comes down to factors. The first round, Sam opens all the doors. Then on all the next rounds, Sam will change doors if they are a multiple of the factor he is going by. So all numbers with an even number of factors will be closed, and all numbers with an odd number of factors will end up open. All numbers have pairs of factors, thus resulting in an even number of factors, except for square numbers who have an odd number of factors because their square root is only listed once. Therefore, all square numbered doors from 1-100 will remain open: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...