# How many bulbs are switched on? [duplicate]

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?

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
6:on
8: off
12:on
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

• Isn't 34 then switched back on by the 34th person? – jafe Nov 13 '18 at 8:39
• 34 has 4 factors, that are 34-1,2,17,34.. so,basically 34 switches it off – gopal Nov 13 '18 at 8:42
• Right, my mistake. – jafe Nov 13 '18 at 8:49
• 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. – elias Nov 13 '18 at 9:45
• @elias can u elaborate it properly.what you are trying to tell with example about n=a*b(a<b). – gopal Nov 13 '18 at 9:59