There are a ton of sqrt functions. I just wanted to post bottom up C solution.

Considering its a 32bit integer input, maximum run time would be a 65,535 iteration.

```
int bulbSwitch(int n) {
int i =1, res=0;
if(!n) return 0;
while((i*i) <= n) {
res+=1;i+=1;
}
return res;
}
```