My teacher asked me a question which is as follow:
There are $1000$ doors numbered $1$ to $1000$, and there are $1000$ men numbered $1$ to $1000$.
Firstly $1$ numbered man goes and open all the doors.
Secondly $2$ numbered man goes and close the doors which are numbered multiple of $2$
Third $3$ numbered man goes and changes the state of doors which are numbered multiple of $3$
For example he closes the door numbered $3$ and opens the door numbered $6$
So after the man numbered $1000$ came back from his work,how many and which doors would be remain opened?
I thought about it for one hour, but couldn't get anything.
My teacher told me that there is a simple & pure mathematical logic behind this
Can you help me with this??
You have to notice that ODD operations means door is open and EVEN operations means door is closed. You can get it with the help of a simple example.
For example: The door number $10$ will be firstly opened by first man and then closed by $2$nd man and then opened by $5$th man and at last closed by $10$th man.
So, what mathematical logic working here is that:
To calculate the number of factors of a number we use the formula $(a+1)(b+1)(c+1).....$ where a,b,c are powers of prime factors of number. Notice that if the number is a perfect square then a,b,c... are all even hence the number of factors ($(a+1)(b+1)(c+1).....$ ) are odd. And if the number is not a perfect square then one of a,b,c... will be odd and hence the number of factors ($(a+1)(b+1)(c+1).....$ ) will become even. So, the perfect square number doors will remain opened.
Or door number $1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961$ will remain opened ($31$ among all).