This question already has an answer here:

I remember this one from an interview:

There is a room with 100 light bulbs (numbered from 1 to 100) lined up in a row. All the bulbs are off. 100 people are lined up in front of the room. The first person enters the room and switches on every bulb, and exits. Then the second person enters and flips the switch on every second bulb (bulbs 2, 4, 6, 8, ... are off). The third person enters and flips the switch on every third bulb (3,6,9,...) and so on until the 100th person exits the room. How many of the light bulbs are on after the 100th person has exited the room?


marked as duplicate by JonMark Perry, ABcDexter, Bass, Oray, Jaap Scherphuis Nov 13 '18 at 9:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Let's choose a bulb, let's say $24$.

Note that it's factors are $1, 2, 3, 4, 6, 8, 12, 24$ now is we give each of our people a number then note that people wearing these numbers are going to touch the switch of the bulb $24$. (It's pretty clear from question $b^{\text{th}}$ person will touch the bulbs from $b$'s multiple)

For $24$

1: Switch on
2: off
3: on
4: off
8: off
24: off
So the numbers with total odd factors will be on at end. Only perfect square have odd factors.
Below and including $100$ there are total $\boxed{10}$ bulbs on.


the answer is 10. the bulbs which will be on are 1,4,9,16,25,36,49,64,81,100. because for this their are no persons to switch it off. for example :34=2*17 i.e if 2 switches it on,it will be switched off by 17

  • 1
    $\begingroup$ Isn't 34 then switched back on by the 34th person? $\endgroup$ – jafe Nov 13 '18 at 8:39
  • 1
    $\begingroup$ 34 has 4 factors, that are 34-1,2,17,34.. so,basically 34 switches it off $\endgroup$ – gopal Nov 13 '18 at 8:42
  • $\begingroup$ Right, my mistake. $\endgroup$ – jafe Nov 13 '18 at 8:49
  • $\begingroup$ Your answer is confusing. First of all, 2 switches 34 off, not on. In general it is not true, that if n=a*b, (a<b), then one of a and b is switching it off, while the other one is switching it on. Also for all the numbers you list there is a person who does a temporary switch-off: for 4, it is person 2, for example, which contradicts your statement of not having a person to switch the bulb off. $\endgroup$ – elias Nov 13 '18 at 9:45
  • $\begingroup$ @elias can u elaborate it properly.what you are trying to tell with example about n=a*b(a<b). $\endgroup$ – gopal Nov 13 '18 at 9:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.