# A jail has 100 cells, numbered 1 to 100. The king Declares some sort of amnesty and orders the following. step 1: make sure all Cells are closed step2: reverse (if open, close; if close, open) those Cells whose numbers are divisible by 1 (in this step, all cells will be Opened); step 3: reverse those that are divisible by 2 (in this step, All even numbered cells will be closed); step 4: reverse those that are Divisible by 3; step 5: reverse those divisible by 4; step 6 to step 101: and so on . . . step 102: release the prisoners in those cells which are finally Open. How many prisoners will be released, and from which cells?

This question is related to Infosys Interview

#### Test

• May 26th, 2005

Result: All those squares below 100 are set free. Like 4,9,16, 25, etc etc

Solution: If we start with a number, like 6, It has factors 2 & 3 which form a pair. So if the jail is set free with 2, it gets closed with 3. But if we take a squared number like 16, it has factors 2, 4, 8 which means that there is a single factor called 4 with which the result can be achieved.

#### raj_893

• Aug 8th, 2005

correct! the logic is all numbers having odd no. of factors will be opened........all squares have odd no. of factors

#### francis

• Sep 1st, 2005

ans 9

#### samhita

• Sep 24th, 2005

3

#### Nitika Gupta

• Sep 29th, 2005

The even numbered cells will be open and odd numbered cells will be closed.

#### ravi

• Sep 29th, 2005

The answer is 1**2 , 2**2 , 3**2 4**2 5**2 6**2 e.t.c

i.e 1,4,9,16,25,36,49,64,81,100

#### kumar

• Mar 20th, 2006

1)all closed

2)all opened(100)

3)50 opened(odd) and 50 closed(even)

4)17 closed(odd),33 opened(odd) & 16 opened(even),34 closed(even)

5)17 closed(odd),33 opened(odd) & 8closed,8opened,17 closed,17 opened

therefore 33+8+17=58 opened.....so obviously 58 out of 100 will be released..

#### Sonali Panda

• Apr 12th, 2006

2.All wiil b Open

3.50 wiil b open ,50 wiil b closed

4.as the no divisible by 2 is not divisible by 3(50 remain open)+33 will be open,ie 83

5.no divisible by 2 will b divisible by 4 =25,so 25 will b closed,so 83-25=58 will b opened

6 to 101 the same,so in 100 times 58 will be open,101(opposite of100),so 42 will be opened,so 102 58 will be opened

ANS:-58 person will be released

#### S.KANNAN

• Jul 30th, 2006

ans is 10 (not 9)i am sure the cell no 1 is open in step 2 and is still b open upto last step.so tat is also included.ans is 10 i am sure about tat

#### vidi56 Profile Answers by vidi56

• May 28th, 2008

10 prisoners will be freed.
1,4,9,16,25,36,49,64,81,100

#### friflow Profile Answers by friflow

• Jun 2nd, 2008

10 perfect squares cell's prisoners are  released.

#### vamsi_krishna475 Profile Answers by vamsi_krishna475

• Dec 26th, 2010

A small modification for the first ans is that, 1 is also opened along with all those perfect squares.