---
# System prepended metadata

title: 0319. Bulb Switcher
tags: [Leetcode, Medium]

---

# 0319. Bulb Switcher
###### tags: `Leetcode` `Medium`
Link: https://leetcode.com/problems/bulb-switcher/
## 思路
找规律 根据每个数的因数个数来判断是否需要关闭/打开
**完全平方数的因数个数是奇数，非完全平方数因数个数为偶数。**
## Code
```java=
class Solution {
    public int bulbSwitch(int n) {
        int count = 0;
        for(int i = 1;i*i<=n;i++){
            count++;
        }
        return count;
    }
}
```
