```
public class Solution {
public int bulbSwitch(int n) {
int i=0;
for(i=1;i*i<=n;i++){
}
return i-1;
}
```

}

The basic idea is to count how many numbers in the range of [1, n] have odd factors. For in the i round, the buld on the position k, which i is a factor of k, will be switched.

If the buld in the position k is on finally, k has odd factors. Only the numbers in this situation: { i | i*i=n, i is an integer} has odd factors.

bulbSwitch(N)=n , n*n=<N<(n+1)(n+1)

=square(N)